@supalive/core 1.8.1 → 1.10.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.
Files changed (106) hide show
  1. package/README.md +1 -2
  2. package/dist/index-BQRlJY_1.d.ts +2192 -0
  3. package/dist/index-BQRlJY_1.d.ts.map +1 -0
  4. package/dist/index-CDG1kbFO.d.ts +2211 -0
  5. package/dist/index-CDG1kbFO.d.ts.map +1 -0
  6. package/dist/index-CkYZi3ai.d.ts +2186 -0
  7. package/dist/index-CkYZi3ai.d.ts.map +1 -0
  8. package/dist/index-D8O39FoZ.d.ts +2192 -0
  9. package/dist/index-D8O39FoZ.d.ts.map +1 -0
  10. package/dist/index-DKlWIC3k.d.ts +2200 -0
  11. package/dist/index-DKlWIC3k.d.ts.map +1 -0
  12. package/dist/index-Dy9UlONo.d.ts +2192 -0
  13. package/dist/index-Dy9UlONo.d.ts.map +1 -0
  14. package/dist/index-WMhtVzJA.d.ts +2192 -0
  15. package/dist/index-WMhtVzJA.d.ts.map +1 -0
  16. package/dist/index-tDcHLwJu.d.ts +2186 -0
  17. package/dist/index-tDcHLwJu.d.ts.map +1 -0
  18. package/dist/mysql-BBNCFz8q.d.ts +109 -0
  19. package/dist/mysql-BBNCFz8q.d.ts.map +1 -0
  20. package/dist/mysql-BVz7201u.d.ts +109 -0
  21. package/dist/mysql-BVz7201u.d.ts.map +1 -0
  22. package/dist/mysql-CBSuONm5.d.ts +109 -0
  23. package/dist/mysql-CBSuONm5.d.ts.map +1 -0
  24. package/dist/mysql-CBlZ6FVc.d.ts +109 -0
  25. package/dist/mysql-CBlZ6FVc.d.ts.map +1 -0
  26. package/dist/mysql-CDenA4XE.d.ts +109 -0
  27. package/dist/mysql-CDenA4XE.d.ts.map +1 -0
  28. package/dist/mysql-CfYZLs5V.d.ts +109 -0
  29. package/dist/mysql-CfYZLs5V.d.ts.map +1 -0
  30. package/dist/mysql-DAfFK5v1.d.ts +109 -0
  31. package/dist/mysql-DAfFK5v1.d.ts.map +1 -0
  32. package/dist/mysql-DjjyCiO4.d.ts +109 -0
  33. package/dist/mysql-DjjyCiO4.d.ts.map +1 -0
  34. package/dist/postgres-BKGLPrKt.d.ts +113 -0
  35. package/dist/postgres-BKGLPrKt.d.ts.map +1 -0
  36. package/dist/postgres-CKBWXyY8.d.ts +113 -0
  37. package/dist/postgres-CKBWXyY8.d.ts.map +1 -0
  38. package/dist/postgres-CUHirAJN.d.ts +113 -0
  39. package/dist/postgres-CUHirAJN.d.ts.map +1 -0
  40. package/dist/postgres-Cj9zuZ8p.d.ts +113 -0
  41. package/dist/postgres-Cj9zuZ8p.d.ts.map +1 -0
  42. package/dist/postgres-DGK6Y1aL.d.ts +113 -0
  43. package/dist/postgres-DGK6Y1aL.d.ts.map +1 -0
  44. package/dist/postgres-DQxKs5Nu.d.ts +113 -0
  45. package/dist/postgres-DQxKs5Nu.d.ts.map +1 -0
  46. package/dist/postgres-hlrVkOXa.d.ts +113 -0
  47. package/dist/postgres-hlrVkOXa.d.ts.map +1 -0
  48. package/dist/postgres-ziXP2hco.d.ts +113 -0
  49. package/dist/postgres-ziXP2hco.d.ts.map +1 -0
  50. package/dist/procedure-B4qKrlBL.js +158 -0
  51. package/dist/procedure-B4qKrlBL.js.map +1 -0
  52. package/dist/procedure-BDcrK98I.js +173 -0
  53. package/dist/procedure-BDcrK98I.js.map +1 -0
  54. package/dist/procedure-BxGOWNWg.js.map +1 -0
  55. package/dist/procedure-CRkrxHvn.js +187 -0
  56. package/dist/procedure-CRkrxHvn.js.map +1 -0
  57. package/dist/procedure-Ck4v3__H.js +212 -0
  58. package/dist/procedure-Ck4v3__H.js.map +1 -0
  59. package/dist/procedure-DPgXC2Cm.js +221 -0
  60. package/dist/procedure-DPgXC2Cm.js.map +1 -0
  61. package/dist/procedure-xUVIUm5W.js +213 -0
  62. package/dist/procedure-xUVIUm5W.js.map +1 -0
  63. package/dist/src/client/index.d.ts +1 -1
  64. package/dist/src/client/index.js +1 -1
  65. package/dist/src/exports/mysql.d.ts +1 -1
  66. package/dist/src/exports/postgres.d.ts +1 -1
  67. package/dist/src/exports/procedure.d.ts +17 -2
  68. package/dist/src/exports/procedure.d.ts.map +1 -0
  69. package/dist/src/exports/procedure.js +8 -2
  70. package/dist/src/exports/procedure.js.map +1 -0
  71. package/dist/src/exports/schema-sql.d.ts +1 -1
  72. package/dist/src/exports/server.d.ts +24 -124
  73. package/dist/src/exports/server.d.ts.map +1 -1
  74. package/dist/src/exports/server.js +128 -30
  75. package/dist/src/exports/server.js.map +1 -1
  76. package/dist/src/exports/sub-manager-worker-entry.d.ts +1 -0
  77. package/dist/src/exports/sub-manager-worker-entry.js +71 -0
  78. package/dist/src/exports/sub-manager-worker-entry.js.map +1 -0
  79. package/dist/src/exports/subscription-manager-worker-entry.js +3 -49
  80. package/dist/src/exports/subscription-manager-worker-entry.js.map +1 -1
  81. package/dist/src/exports/types.d.ts +2 -2
  82. package/dist/sub-worker-dispatch-G8V8asfR.js +810 -0
  83. package/dist/sub-worker-dispatch-G8V8asfR.js.map +1 -0
  84. package/dist/subscription-worker-dispatch-CSQV-PO3.js +810 -0
  85. package/dist/subscription-worker-dispatch-CSQV-PO3.js.map +1 -0
  86. package/dist/types_server-AQ8Jl2_R.d.ts +521 -0
  87. package/dist/types_server-AQ8Jl2_R.d.ts.map +1 -0
  88. package/dist/types_server-BB2WvXEA.d.ts +521 -0
  89. package/dist/types_server-BB2WvXEA.d.ts.map +1 -0
  90. package/dist/types_server-BI7uQd6x.d.ts +328 -0
  91. package/dist/types_server-BI7uQd6x.d.ts.map +1 -0
  92. package/dist/types_server-BcT4A8OM.d.ts +328 -0
  93. package/dist/types_server-BcT4A8OM.d.ts.map +1 -0
  94. package/dist/types_server-CO3IYNS9.d.ts +328 -0
  95. package/dist/types_server-CO3IYNS9.d.ts.map +1 -0
  96. package/dist/types_server-Clf74qZP.d.ts +328 -0
  97. package/dist/types_server-Clf74qZP.d.ts.map +1 -0
  98. package/dist/types_server-DEAwXI4p.d.ts +328 -0
  99. package/dist/types_server-DEAwXI4p.d.ts.map +1 -0
  100. package/dist/types_server-DU9JMSXd.d.ts +521 -0
  101. package/dist/types_server-DU9JMSXd.d.ts.map +1 -0
  102. package/dist/zod_ext-B5cyjWqZ.d.ts +11 -0
  103. package/dist/zod_ext-B5cyjWqZ.d.ts.map +1 -0
  104. package/dist/zod_ext-CZlJ4wtJ.d.ts +11 -0
  105. package/dist/zod_ext-CZlJ4wtJ.d.ts.map +1 -0
  106. package/package.json +6 -5
@@ -0,0 +1,221 @@
1
+ import { z as z$2 } from "zod";
2
+ //#region src/router/procedure.ts
3
+ /**
4
+ * Patch all Zod schema types on the given `z` namespace with `.modelName(name)`.
5
+ * Must be called with the same `z` instance the consumer uses so the prototypes
6
+ * match. Runs once per unique `z` instance (tracked via a WeakSet).
7
+ */
8
+ function patchZod(zInstance) {
9
+ const key = "__supalivePatchedZodInstances";
10
+ const patchedInstances = globalThis[key] ??= /* @__PURE__ */ new Set();
11
+ if (patchedInstances.has(zInstance)) return;
12
+ patchedInstances.add(zInstance);
13
+ const patched = /* @__PURE__ */ new Set();
14
+ const samples = [
15
+ zInstance.string(),
16
+ zInstance.number(),
17
+ zInstance.boolean(),
18
+ zInstance.bigint(),
19
+ zInstance.date(),
20
+ zInstance.object({}),
21
+ zInstance.array(zInstance.string()),
22
+ zInstance.enum(["_"]),
23
+ zInstance.literal("_"),
24
+ zInstance.null(),
25
+ zInstance.undefined(),
26
+ zInstance.any(),
27
+ zInstance.unknown(),
28
+ zInstance.void(),
29
+ zInstance.never(),
30
+ zInstance.nan(),
31
+ zInstance.record(zInstance.string(), zInstance.string()),
32
+ zInstance.union([zInstance.string(), zInstance.number()]),
33
+ zInstance.intersection(zInstance.string(), zInstance.string()),
34
+ zInstance.tuple([zInstance.string()]),
35
+ zInstance.promise(zInstance.string()),
36
+ zInstance.custom(),
37
+ zInstance.coerce.string(),
38
+ zInstance.coerce.number(),
39
+ zInstance.coerce.boolean(),
40
+ zInstance.coerce.bigint(),
41
+ zInstance.coerce.date(),
42
+ zInstance.string().optional(),
43
+ zInstance.string().nullable(),
44
+ zInstance.string().default(""),
45
+ zInstance.string().pipe(zInstance.string()),
46
+ zInstance.string().transform(() => "")
47
+ ];
48
+ for (const inst of samples) {
49
+ const proto = Object.getPrototypeOf(inst);
50
+ if (patched.has(proto)) continue;
51
+ patched.add(proto);
52
+ const metaDesc = Object.getOwnPropertyDescriptor(proto, "meta");
53
+ if (!metaDesc || !metaDesc.get) continue;
54
+ if (proto.modelName) continue;
55
+ Object.defineProperty(proto, "modelName", {
56
+ value: function modelName(name) {
57
+ return this.meta({ __genType: name });
58
+ },
59
+ writable: true,
60
+ configurable: true
61
+ });
62
+ }
63
+ }
64
+ patchZod(z$2);
65
+ /**
66
+ * Create a query builder with a pre-defined context type.
67
+ * This allows you to define the context type once and have it inferred
68
+ * automatically in all your query handlers.
69
+ *
70
+ * @example
71
+ * // Define your server context
72
+ * interface ServerContext {
73
+ * auth: { userId: string };
74
+ * requestId: string;
75
+ * }
76
+ *
77
+ * // Create a typed query builder
78
+ * const query = createQueryBuilder<ServerContext>();
79
+ *
80
+ * // Use it - context type is automatically inferred!
81
+ * const getUser = query({
82
+ * args: z.object({ id: z.string() }),
83
+ * handler: async (ctx, { id }) => {
84
+ * // ctx.db for database queries
85
+ * const user = await ctx.db.query(UsersSchema).find(id);
86
+ * // ctx.context for server context
87
+ * console.log(ctx.context.requestId);
88
+ * return user;
89
+ * }
90
+ * });
91
+ */
92
+ function createQueryBuilder() {
93
+ return function query(config) {
94
+ return {
95
+ _type: "procedure",
96
+ procedureType: "query",
97
+ inputSchema: config.args,
98
+ outputSchema: config.returns,
99
+ fn: config.handler,
100
+ internal: config.internal ?? false,
101
+ queryIdentity: config.queryIdentity
102
+ };
103
+ };
104
+ }
105
+ /**
106
+ * Create a mutation builder with a pre-defined context type.
107
+ * This allows you to define the context type once and have it inferred
108
+ * automatically in all your mutation handlers.
109
+ *
110
+ * @example
111
+ * // Define your server context
112
+ * interface ServerContext {
113
+ * auth: { userId: string };
114
+ * requestId: string;
115
+ * }
116
+ *
117
+ * // Create a typed mutation builder
118
+ * const mutation = createMutationBuilder<ServerContext>();
119
+ *
120
+ * // Use it - context type is automatically inferred!
121
+ * const createUser = mutation({
122
+ * args: z.object({ name: z.string() }),
123
+ * handler: async (ctx, { name }) => {
124
+ * // ctx.db for mutations
125
+ * await ctx.db.insert(UsersSchema, id, { name });
126
+ * // ctx.context for server context
127
+ * console.log(ctx.context.requestId);
128
+ * return { success: true };
129
+ * }
130
+ * });
131
+ */
132
+ function createMutationBuilder() {
133
+ return function mutation(config) {
134
+ return {
135
+ _type: "procedure",
136
+ procedureType: "mutation",
137
+ inputSchema: config.args,
138
+ outputSchema: config.returns,
139
+ fn: config.handler,
140
+ internal: config.internal ?? false
141
+ };
142
+ };
143
+ }
144
+ /**
145
+ * Create an action builder with a pre-defined context type.
146
+ * Actions have access to the full SupaliveDb for both queries and mutations.
147
+ *
148
+ * @example
149
+ * // Define your server context
150
+ * interface ServerContext {
151
+ * auth: { userId: string };
152
+ * requestId: string;
153
+ * }
154
+ *
155
+ * // Create a typed action builder
156
+ * const action = createActionBuilder<ServerContext>();
157
+ *
158
+ * // Use it - context type is automatically inferred!
159
+ * const processOrder = action({
160
+ * args: z.object({ orderId: z.string() }),
161
+ * handler: async (ctx, { orderId }) => {
162
+ * // ctx.db for full database access
163
+ * const order = await ctx.db.query(async (db) => {
164
+ * return db.query(OrdersSchema).find(orderId);
165
+ * });
166
+ * await ctx.db.mutation(async (db) => {
167
+ * await db.update(OrdersSchema, orderId, { status: "processed" });
168
+ * });
169
+ * // ctx.context for server context
170
+ * console.log(ctx.context.requestId);
171
+ * return { success: true };
172
+ * }
173
+ * });
174
+ */
175
+ function createActionBuilder() {
176
+ return function action(config) {
177
+ return {
178
+ _type: "procedure",
179
+ procedureType: "action",
180
+ inputSchema: config.args,
181
+ outputSchema: config.returns,
182
+ fn: config.handler,
183
+ internal: config.internal ?? false
184
+ };
185
+ };
186
+ }
187
+ /**
188
+ * Create a job builder with a pre-defined context type. A job is a
189
+ * server-only procedure invoked by the scheduler over HTTP — either on its
190
+ * declared `cron` schedule or as a precise one-shot enqueued via the
191
+ * server's job API. Jobs run like actions (full db, non-transactional) and
192
+ * are always internal, so they are never reachable from a client.
193
+ *
194
+ * @example
195
+ * const job = createJobBuilder<ServerContext>();
196
+ *
197
+ * export const cleanupOtps = job({
198
+ * cron: "0 * * * *", // hourly
199
+ * args: z.object({}),
200
+ * handler: async (ctx) => {
201
+ * await ctx.db.mutation(async (db) => { ... });
202
+ * return { ok: true };
203
+ * },
204
+ * });
205
+ */
206
+ function createJobBuilder() {
207
+ return function job(config) {
208
+ return {
209
+ _type: "procedure",
210
+ procedureType: "job",
211
+ inputSchema: config.args,
212
+ fn: config.handler,
213
+ internal: true,
214
+ cron: config.cron
215
+ };
216
+ };
217
+ }
218
+ //#endregion
219
+ export { patchZod as a, createQueryBuilder as i, createJobBuilder as n, z$2 as o, createMutationBuilder as r, createActionBuilder as t };
220
+
221
+ //# sourceMappingURL=procedure-DPgXC2Cm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"procedure-DPgXC2Cm.js","names":["z"],"sources":["../src/router/procedure.ts"],"sourcesContent":["import type { ZodType } from \"zod\";\nimport { z } from \"zod\";\nimport type { DbReader, DbWriter } from \"../db/context\";\nimport type { SupaliveDb } from \"../db/realtime_db\";\nimport type { ObjectStorage } from \"../storage\";\nimport type { JobClient } from \"../jobs/scheduler\";\n\nexport { z };\n\n// ─── Zod .modelName() extension ─────────────────────────────────────────────\n// Patches every Zod schema type with a `.modelName(\"Name\")` method that sets\n// `__genType` metadata for codegen model renaming.\n//\n// Zod v4: `z.string` is a factory — `z.string.prototype` is NOT the real class\n// prototype. We collect the actual prototypes by creating one instance per type,\n// then patch each unique prototype once.\n\n/**\n * Patch all Zod schema types on the given `z` namespace with `.modelName(name)`.\n * Must be called with the same `z` instance the consumer uses so the prototypes\n * match. Runs once per unique `z` instance (tracked via a WeakSet).\n */\nexport function patchZod(zInstance: typeof z): void {\n const key = \"__supalivePatchedZodInstances\";\n const patchedInstances: Set<object> = (globalThis as any)[key] ??= new Set();\n if (patchedInstances.has(zInstance)) return;\n patchedInstances.add(zInstance);\n\n const patched = new Set<object>();\n const samples: ZodType[] = [\n zInstance.string(), zInstance.number(), zInstance.boolean(), zInstance.bigint(), zInstance.date(),\n zInstance.object({}), zInstance.array(zInstance.string()), zInstance.enum([\"_\"]),\n zInstance.literal(\"_\"), zInstance.null(), zInstance.undefined(), zInstance.any(), zInstance.unknown(),\n zInstance.void(), zInstance.never(), zInstance.nan(), zInstance.record(zInstance.string(), zInstance.string()),\n zInstance.union([zInstance.string(), zInstance.number()]), zInstance.intersection(zInstance.string(), zInstance.string()),\n zInstance.tuple([zInstance.string()]), zInstance.promise(zInstance.string()), zInstance.custom(),\n zInstance.coerce.string(), zInstance.coerce.number(), zInstance.coerce.boolean(),\n zInstance.coerce.bigint(), zInstance.coerce.date(),\n zInstance.string().optional(), zInstance.string().nullable(), zInstance.string().default(\"\"),\n zInstance.string().pipe(zInstance.string()), zInstance.string().transform(() => \"\"),\n ];\n for (const inst of samples) {\n const proto = Object.getPrototypeOf(inst);\n if (patched.has(proto)) continue;\n patched.add(proto);\n const metaDesc = Object.getOwnPropertyDescriptor(proto, \"meta\");\n if (!metaDesc || !metaDesc.get) continue;\n if ((proto as any).modelName) continue;\n Object.defineProperty(proto, \"modelName\", {\n value: function modelName(name: string) {\n return this.meta({ __genType: name });\n },\n writable: true,\n configurable: true,\n });\n }\n}\n\n// Auto-patch this module's own z instance so the re-exported z already has .modelName()\npatchZod(z);\n\n// ─── Context Types ───────────────────────────────────────────────────────────\n\n/**\n * Query context passed to query handlers.\n * Contains database reader and user-defined server context.\n */\nexport interface QueryCtx<TContext = unknown> {\n /** Database reader for queries */\n db: DbReader;\n /** User-defined server context (auth, requestId, etc.) */\n serverCtx?: TContext;\n}\n\n/**\n * Mutation context passed to mutation handlers.\n * Contains database writer and user-defined server context.\n */\nexport interface MutationCtx<TContext = unknown> {\n /** Database writer for mutations (includes insert/update/delete) */\n db: DbWriter;\n /** User-defined server context (auth, requestId, etc.) */\n serverCtx?: TContext;\n}\n\n/**\n * Action context passed to action handlers.\n *\n * Actions are the \"external I/O\" tier: they hold the full {@link SupaliveDb}\n * (queries + mutations) and are the ONLY context that also carries side-effect\n * services — {@link ObjectStorage} for uploads/downloads and a {@link JobClient}\n * for scheduling precise one-shots. Queries/mutations stay pure (db only) so\n * they remain cacheable and transaction-scoped.\n */\nexport interface ActionCtx<TContext = unknown> {\n /** Full database interface for queries and mutations */\n db: SupaliveDb;\n /** Object storage, when the server was configured with one (see\n * `SupaliveServerConfig.storage`); `undefined` otherwise. The usual home\n * for upload/download presigning. */\n storage: ObjectStorage;\n /** Job scheduler client for enqueueing precise one-shots, when the server\n * was configured with a `scheduler`; `undefined` otherwise. Scheduling is\n * network I/O, so it belongs in actions, never inside a DB transaction. */\n scheduler: JobClient;\n /** User-defined server context (auth, requestId, etc.) */\n serverCtx?: TContext;\n}\n\n/**\n * Job context passed to job handlers. Structurally identical to\n * {@link ActionCtx}: a job is a server-only procedure that runs\n * non-transactionally against the full {@link SupaliveDb} and may perform\n * external work, but it is triggered by the scheduler over HTTP (a cron tick\n * or a precise one-shot) rather than by a connected client. `serverCtx` is\n * the system context built by the server's `jobContext` factory.\n */\nexport interface JobCtx<TContext = unknown> {\n /** Full database interface for queries and mutations */\n db: SupaliveDb;\n /** System server context built by the server for scheduler-triggered runs */\n serverCtx?: TContext;\n}\n\n/**\n * Context handed to `caller.<proc>.runQuery` / `.runMutation` when invoking one\n * procedure from inside another. Pass the caller handler's own `ctx` — its `db`\n * carries the parent's live transaction (a {@link DbReader}/{@link DbWriter}) or,\n * inside an action, the full {@link SupaliveDb}. The caller uses this to decide\n * whether the nested call joins the parent's snapshot (queries) or runs as an\n * independent sub-transaction (mutations).\n */\nexport interface ParentCtx<TContext = unknown> {\n db: DbReader | DbWriter | SupaliveDb;\n serverCtx?: TContext | undefined;\n}\n\n// ─── Procedure Types ─────────────────────────────────────────────────────────\n\nexport type QueryFn<TInput, TResult, TContext = unknown> = (\n ctx: QueryCtx<TContext>,\n input: TInput,\n) => Promise<TResult>;\n\nexport type MutationFn<TInput, TResult, TContext = unknown> = (\n ctx: MutationCtx<TContext>,\n input: TInput,\n) => Promise<TResult>;\n\nexport type ActionFn<TInput, TResult, TContext = unknown> = (\n ctx: ActionCtx<TContext>,\n input: TInput,\n) => Promise<TResult>;\n\nexport type JobFn<TInput, TResult, TContext = unknown> = (\n ctx: JobCtx<TContext>,\n input: TInput,\n) => Promise<TResult>;\n\n/**\n * Per-procedure override for the cache/subscription segmentation key.\n *\n * omitted | undefined → fall back to `config.getUserId(serverCtx)` (default)\n * false → no identity in hash; cache/sub shared across all users\n * string → a static identity literal (e.g. \"public\" or a tenant id)\n * function → compute from serverCtx + input (sync)\n *\n * When the result of a query is identical regardless of who calls it, set\n * this to a literal (or `false`) so a single cache entry serves everyone.\n *\n * The function form intentionally takes `serverCtx` (not the full `QueryCtx`)\n * because identity is resolved before any DB read is issued.\n */\nexport type QueryIdentitySpec<TInput, TContext> =\n | false\n | string\n | ((serverCtx: TContext, input: TInput) => string | null | undefined);\n\nexport interface BaseProcedure<\n TInput, TResult,\n TType extends \"query\" | \"mutation\" | \"action\" | \"job\",\n TContext = unknown,\n TInternal extends boolean = boolean\n> {\n readonly _type: \"procedure\";\n readonly procedureType: TType;\n readonly inputSchema: ZodType<TInput>;\n readonly outputSchema?: ZodType<any>;\n readonly fn: QueryFn<TInput, TResult, TContext> | MutationFn<TInput, TResult, TContext> | ActionFn<TInput, TResult, TContext> | JobFn<TInput, TResult, TContext>;\n readonly internal: TInternal;\n}\n\nexport interface QueryProcedure<\n TInput, TResult,\n TContext = unknown,\n TInternal extends boolean = boolean\n> extends BaseProcedure<TInput, TResult, \"query\", TContext, TInternal> {\n readonly procedureType: \"query\";\n readonly fn: QueryFn<TInput, TResult, TContext>;\n readonly queryIdentity?: QueryIdentitySpec<TInput, TContext>;\n}\n\nexport interface MutationProcedure<\n TInput, TResult,\n TContext = unknown,\n TInternal extends boolean = boolean\n> extends BaseProcedure<TInput, TResult, \"mutation\", TContext, TInternal> {\n readonly procedureType: \"mutation\";\n readonly fn: MutationFn<TInput, TResult, TContext>;\n}\n\nexport interface ActionProcedure<\n TInput, TResult,\n TContext = unknown,\n TInternal extends boolean = boolean\n> extends BaseProcedure<TInput, TResult, \"action\", TContext, TInternal> {\n readonly procedureType: \"action\";\n readonly fn: ActionFn<TInput, TResult, TContext>;\n}\n\n/**\n * A scheduler-triggered, server-only procedure. Runs like an action (full\n * db, non-transactional, may do external work) but is dispatched by the\n * server's HTTP job endpoint on a cron tick or a precise one-shot rather\n * than over the client WebSocket. Always {@link internal}: true, so it is\n * never reachable via `call`/`subscribe`.\n */\nexport interface JobProcedure<\n TInput, TResult,\n TContext = unknown,\n> extends BaseProcedure<TInput, TResult, \"job\", TContext, true> {\n readonly procedureType: \"job\";\n readonly fn: JobFn<TInput, TResult, TContext>;\n /**\n * Cron expression for a recurring job (e.g. `\"0 3 * * *\"`). Declared crons\n * are synced to the scheduler at server startup. Omit for a job that is\n * only ever invoked as a precise one-shot via the scheduler API.\n */\n readonly cron?: string;\n}\n\nexport type AnyProcedure<TContext = unknown> =\n | QueryProcedure<any, any, TContext>\n | MutationProcedure<any, any, TContext>\n | ActionProcedure<any, any, TContext>\n | JobProcedure<any, any, TContext>;\n\n// ─── Procedure Configuration Types ───────────────────────────────────────────\n\nexport interface QueryConfig<TInput, TResult, TContext = unknown> {\n /** Zod schema for input validation */\n args: ZodType<TInput>;\n /** The query handler function */\n handler: QueryFn<TInput, TResult, TContext>;\n /** Mark as internal (server-only). Default: false */\n internal?: boolean;\n /**\n * Optional Zod schema describing return-type overrides for codegen.\n * Only the fields you specify are overridden; everything else is inferred\n * from the handler's TypeScript return type. Use `.modelName(\"Name\")`\n * on a Zod object to rename the generated model class.\n */\n returns?: ZodType<any>;\n /**\n * Override the cache/subscription segmentation key for this procedure.\n * See {@link QueryIdentitySpec}. Omit to keep the default (per-user) behavior.\n */\n queryIdentity?: QueryIdentitySpec<TInput, TContext>;\n}\n\nexport interface MutationConfig<TInput, TResult, TContext = unknown> {\n /** Zod schema for input validation */\n args: ZodType<TInput>;\n /** The mutation handler function */\n handler: MutationFn<TInput, TResult, TContext>;\n /** Mark as internal (server-only). Default: false */\n internal?: boolean;\n /**\n * Optional Zod schema describing return-type overrides for codegen.\n * Only the fields you specify are overridden; everything else is inferred\n * from the handler's TypeScript return type.\n */\n returns?: ZodType<any>;\n}\n\nexport interface ActionConfig<TInput, TResult, TContext = unknown> {\n /** Zod schema for input validation */\n args: ZodType<TInput>;\n /** The action handler function */\n handler: ActionFn<TInput, TResult, TContext>;\n /** Mark as internal (server-only). Default: false */\n internal?: boolean;\n /**\n * Optional Zod schema describing return-type overrides for codegen.\n * Only the fields you specify are overridden; everything else is inferred\n * from the handler's TypeScript return type.\n */\n returns?: ZodType<any>;\n}\n\nexport interface JobConfig<TInput, TResult, TContext = unknown> {\n /** Zod schema for the job payload */\n args: ZodType<TInput>;\n /** The job handler function */\n handler: JobFn<TInput, TResult, TContext>;\n /**\n * Cron expression for a recurring schedule (e.g. `\"0 3 * * *\"`). Omit for a\n * job that is only invoked as a precise one-shot.\n */\n cron?: string;\n}\n\n/** Extract input type from a procedure */\nexport type InputOf<T> = T extends BaseProcedure<infer I, any, any, any> ? I : never;\n\n/** Extract output type from a procedure */\nexport type OutputOf<T> = T extends BaseProcedure<any, infer O, any, any> ? O : never;\n\n/** Extract procedure type (query/mutation) */\nexport type TypeOf<T> = T extends BaseProcedure<any, any, infer Type, any> ? Type : never;\n\n/** Extract server context type from a procedure */\nexport type ContextOf<T> = T extends BaseProcedure<any, any, any, infer C> ? C : never;\n\n/**\n * Create a query builder with a pre-defined context type.\n * This allows you to define the context type once and have it inferred\n * automatically in all your query handlers.\n * \n * @example\n * // Define your server context\n * interface ServerContext {\n * auth: { userId: string };\n * requestId: string;\n * }\n * \n * // Create a typed query builder\n * const query = createQueryBuilder<ServerContext>();\n * \n * // Use it - context type is automatically inferred!\n * const getUser = query({\n * args: z.object({ id: z.string() }),\n * handler: async (ctx, { id }) => {\n * // ctx.db for database queries\n * const user = await ctx.db.query(UsersSchema).find(id);\n * // ctx.context for server context\n * console.log(ctx.context.requestId);\n * return user;\n * }\n * });\n */\nexport function createQueryBuilder<TContext = unknown>() {\n return function query<TInput, TResult, const TInternal extends boolean = false>(\n config: QueryConfig<TInput, TResult, TContext> & { internal?: TInternal }\n ): QueryProcedure<TInput, TResult, TContext, TInternal> {\n return {\n _type: \"procedure\",\n procedureType: \"query\",\n inputSchema: config.args,\n outputSchema: config.returns,\n fn: config.handler,\n internal: (config.internal ?? false) as TInternal,\n queryIdentity: config.queryIdentity,\n };\n };\n}\n\n// ─── Mutation Builder Factory ────────────────────────────────────────────────\n\n/**\n * Create a mutation builder with a pre-defined context type.\n * This allows you to define the context type once and have it inferred\n * automatically in all your mutation handlers.\n * \n * @example\n * // Define your server context\n * interface ServerContext {\n * auth: { userId: string };\n * requestId: string;\n * }\n * \n * // Create a typed mutation builder\n * const mutation = createMutationBuilder<ServerContext>();\n * \n * // Use it - context type is automatically inferred!\n * const createUser = mutation({\n * args: z.object({ name: z.string() }),\n * handler: async (ctx, { name }) => {\n * // ctx.db for mutations\n * await ctx.db.insert(UsersSchema, id, { name });\n * // ctx.context for server context\n * console.log(ctx.context.requestId);\n * return { success: true };\n * }\n * });\n */\nexport function createMutationBuilder<TContext = unknown>() {\n return function mutation<TInput, TResult, const TInternal extends boolean = false>(\n config: MutationConfig<TInput, TResult, TContext> & { internal?: TInternal }\n ): MutationProcedure<TInput, TResult, TContext, TInternal> {\n return {\n _type: \"procedure\",\n procedureType: \"mutation\",\n inputSchema: config.args,\n outputSchema: config.returns,\n fn: config.handler,\n internal: (config.internal ?? false) as TInternal,\n };\n };\n}\n\n// ─── Action Builder Factory ──────────────────────────────────────────────────\n\n/**\n * Create an action builder with a pre-defined context type.\n * Actions have access to the full SupaliveDb for both queries and mutations.\n *\n * @example\n * // Define your server context\n * interface ServerContext {\n * auth: { userId: string };\n * requestId: string;\n * }\n *\n * // Create a typed action builder\n * const action = createActionBuilder<ServerContext>();\n *\n * // Use it - context type is automatically inferred!\n * const processOrder = action({\n * args: z.object({ orderId: z.string() }),\n * handler: async (ctx, { orderId }) => {\n * // ctx.db for full database access\n * const order = await ctx.db.query(async (db) => {\n * return db.query(OrdersSchema).find(orderId);\n * });\n * await ctx.db.mutation(async (db) => {\n * await db.update(OrdersSchema, orderId, { status: \"processed\" });\n * });\n * // ctx.context for server context\n * console.log(ctx.context.requestId);\n * return { success: true };\n * }\n * });\n */\nexport function createActionBuilder<TContext = unknown>() {\n return function action<TInput, TResult, const TInternal extends boolean = false>(\n config: ActionConfig<TInput, TResult, TContext> & { internal?: TInternal }\n ): ActionProcedure<TInput, TResult, TContext, TInternal> {\n return {\n _type: \"procedure\",\n procedureType: \"action\",\n inputSchema: config.args,\n outputSchema: config.returns,\n fn: config.handler,\n internal: (config.internal ?? false) as TInternal,\n };\n };\n}\n\n// ─── Job Builder Factory ─────────────────────────────────────────────────────\n\n/**\n * Create a job builder with a pre-defined context type. A job is a\n * server-only procedure invoked by the scheduler over HTTP — either on its\n * declared `cron` schedule or as a precise one-shot enqueued via the\n * server's job API. Jobs run like actions (full db, non-transactional) and\n * are always internal, so they are never reachable from a client.\n *\n * @example\n * const job = createJobBuilder<ServerContext>();\n *\n * export const cleanupOtps = job({\n * cron: \"0 * * * *\", // hourly\n * args: z.object({}),\n * handler: async (ctx) => {\n * await ctx.db.mutation(async (db) => { ... });\n * return { ok: true };\n * },\n * });\n */\nexport function createJobBuilder<TContext = unknown>() {\n return function job<TInput, TResult>(\n config: JobConfig<TInput, TResult, TContext>\n ): JobProcedure<TInput, TResult, TContext> {\n return {\n _type: \"procedure\",\n procedureType: \"job\",\n inputSchema: config.args,\n fn: config.handler,\n internal: true,\n cron: config.cron,\n };\n };\n}"],"mappings":"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"}
@@ -0,0 +1,213 @@
1
+ import { z as z$1 } from "zod";
2
+ //#region src/router/procedure.ts
3
+ if (!globalThis.__supaliveModelNamePatched) {
4
+ const patched = /* @__PURE__ */ new Set();
5
+ const samples = [
6
+ z$1.string(),
7
+ z$1.number(),
8
+ z$1.boolean(),
9
+ z$1.bigint(),
10
+ z$1.date(),
11
+ z$1.object({}),
12
+ z$1.array(z$1.string()),
13
+ z$1.enum(["_"]),
14
+ z$1.literal("_"),
15
+ z$1.null(),
16
+ z$1.undefined(),
17
+ z$1.any(),
18
+ z$1.unknown(),
19
+ z$1.void(),
20
+ z$1.never(),
21
+ z$1.nan(),
22
+ z$1.record(z$1.string(), z$1.string()),
23
+ z$1.union([z$1.string(), z$1.number()]),
24
+ z$1.intersection(z$1.string(), z$1.string()),
25
+ z$1.tuple([z$1.string()]),
26
+ z$1.promise(z$1.string()),
27
+ z$1.custom(),
28
+ z$1.coerce.string(),
29
+ z$1.coerce.number(),
30
+ z$1.coerce.boolean(),
31
+ z$1.coerce.bigint(),
32
+ z$1.coerce.date(),
33
+ z$1.string().optional(),
34
+ z$1.string().nullable(),
35
+ z$1.string().default(""),
36
+ z$1.string().pipe(z$1.string()),
37
+ z$1.string().transform(() => "")
38
+ ];
39
+ for (const inst of samples) {
40
+ const proto = Object.getPrototypeOf(inst);
41
+ if (patched.has(proto)) continue;
42
+ patched.add(proto);
43
+ const metaDesc = Object.getOwnPropertyDescriptor(proto, "meta");
44
+ if (!metaDesc || !metaDesc.get) continue;
45
+ if (proto.modelName) continue;
46
+ Object.defineProperty(proto, "modelName", {
47
+ value: function modelName(name) {
48
+ return this.meta({ __genType: name });
49
+ },
50
+ writable: true,
51
+ configurable: true
52
+ });
53
+ }
54
+ globalThis.__supaliveModelNamePatched = true;
55
+ globalThis.__supalivePatchedCount = patched.size;
56
+ }
57
+ /**
58
+ * Create a query builder with a pre-defined context type.
59
+ * This allows you to define the context type once and have it inferred
60
+ * automatically in all your query handlers.
61
+ *
62
+ * @example
63
+ * // Define your server context
64
+ * interface ServerContext {
65
+ * auth: { userId: string };
66
+ * requestId: string;
67
+ * }
68
+ *
69
+ * // Create a typed query builder
70
+ * const query = createQueryBuilder<ServerContext>();
71
+ *
72
+ * // Use it - context type is automatically inferred!
73
+ * const getUser = query({
74
+ * args: z.object({ id: z.string() }),
75
+ * handler: async (ctx, { id }) => {
76
+ * // ctx.db for database queries
77
+ * const user = await ctx.db.query(UsersSchema).find(id);
78
+ * // ctx.context for server context
79
+ * console.log(ctx.context.requestId);
80
+ * return user;
81
+ * }
82
+ * });
83
+ */
84
+ function createQueryBuilder() {
85
+ return function query(config) {
86
+ return {
87
+ _type: "procedure",
88
+ procedureType: "query",
89
+ inputSchema: config.args,
90
+ outputSchema: config.returns,
91
+ fn: config.handler,
92
+ internal: config.internal ?? false,
93
+ queryIdentity: config.queryIdentity
94
+ };
95
+ };
96
+ }
97
+ /**
98
+ * Create a mutation builder with a pre-defined context type.
99
+ * This allows you to define the context type once and have it inferred
100
+ * automatically in all your mutation handlers.
101
+ *
102
+ * @example
103
+ * // Define your server context
104
+ * interface ServerContext {
105
+ * auth: { userId: string };
106
+ * requestId: string;
107
+ * }
108
+ *
109
+ * // Create a typed mutation builder
110
+ * const mutation = createMutationBuilder<ServerContext>();
111
+ *
112
+ * // Use it - context type is automatically inferred!
113
+ * const createUser = mutation({
114
+ * args: z.object({ name: z.string() }),
115
+ * handler: async (ctx, { name }) => {
116
+ * // ctx.db for mutations
117
+ * await ctx.db.insert(UsersSchema, id, { name });
118
+ * // ctx.context for server context
119
+ * console.log(ctx.context.requestId);
120
+ * return { success: true };
121
+ * }
122
+ * });
123
+ */
124
+ function createMutationBuilder() {
125
+ return function mutation(config) {
126
+ return {
127
+ _type: "procedure",
128
+ procedureType: "mutation",
129
+ inputSchema: config.args,
130
+ outputSchema: config.returns,
131
+ fn: config.handler,
132
+ internal: config.internal ?? false
133
+ };
134
+ };
135
+ }
136
+ /**
137
+ * Create an action builder with a pre-defined context type.
138
+ * Actions have access to the full SupaliveDb for both queries and mutations.
139
+ *
140
+ * @example
141
+ * // Define your server context
142
+ * interface ServerContext {
143
+ * auth: { userId: string };
144
+ * requestId: string;
145
+ * }
146
+ *
147
+ * // Create a typed action builder
148
+ * const action = createActionBuilder<ServerContext>();
149
+ *
150
+ * // Use it - context type is automatically inferred!
151
+ * const processOrder = action({
152
+ * args: z.object({ orderId: z.string() }),
153
+ * handler: async (ctx, { orderId }) => {
154
+ * // ctx.db for full database access
155
+ * const order = await ctx.db.query(async (db) => {
156
+ * return db.query(OrdersSchema).find(orderId);
157
+ * });
158
+ * await ctx.db.mutation(async (db) => {
159
+ * await db.update(OrdersSchema, orderId, { status: "processed" });
160
+ * });
161
+ * // ctx.context for server context
162
+ * console.log(ctx.context.requestId);
163
+ * return { success: true };
164
+ * }
165
+ * });
166
+ */
167
+ function createActionBuilder() {
168
+ return function action(config) {
169
+ return {
170
+ _type: "procedure",
171
+ procedureType: "action",
172
+ inputSchema: config.args,
173
+ outputSchema: config.returns,
174
+ fn: config.handler,
175
+ internal: config.internal ?? false
176
+ };
177
+ };
178
+ }
179
+ /**
180
+ * Create a job builder with a pre-defined context type. A job is a
181
+ * server-only procedure invoked by the scheduler over HTTP — either on its
182
+ * declared `cron` schedule or as a precise one-shot enqueued via the
183
+ * server's job API. Jobs run like actions (full db, non-transactional) and
184
+ * are always internal, so they are never reachable from a client.
185
+ *
186
+ * @example
187
+ * const job = createJobBuilder<ServerContext>();
188
+ *
189
+ * export const cleanupOtps = job({
190
+ * cron: "0 * * * *", // hourly
191
+ * args: z.object({}),
192
+ * handler: async (ctx) => {
193
+ * await ctx.db.mutation(async (db) => { ... });
194
+ * return { ok: true };
195
+ * },
196
+ * });
197
+ */
198
+ function createJobBuilder() {
199
+ return function job(config) {
200
+ return {
201
+ _type: "procedure",
202
+ procedureType: "job",
203
+ inputSchema: config.args,
204
+ fn: config.handler,
205
+ internal: true,
206
+ cron: config.cron
207
+ };
208
+ };
209
+ }
210
+ //#endregion
211
+ export { createQueryBuilder as i, createJobBuilder as n, createMutationBuilder as r, createActionBuilder as t };
212
+
213
+ //# sourceMappingURL=procedure-xUVIUm5W.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"procedure-xUVIUm5W.js","names":["z"],"sources":["../src/router/procedure.ts"],"sourcesContent":["import type { ZodType } from \"zod\";\nimport { z } from \"zod\";\nimport type { DbReader, DbWriter } from \"../db/context\";\nimport type { SupaliveDb } from \"../db/realtime_db\";\nimport type { ObjectStorage } from \"../storage\";\nimport type { JobClient } from \"../jobs/scheduler\";\n\n// ─── Zod .modelName() extension ─────────────────────────────────────────────\n// Patches every Zod schema type with a `.modelName(\"Name\")` method that sets\n// `__genType` metadata for codegen model renaming. Runs once at import time.\n//\n// Zod v4: `z.string` is a factory — `z.string.prototype` is NOT the real class\n// prototype. We collect the actual prototypes by creating one instance per type,\n// then patch each unique prototype once.\nif (!(globalThis as any).__supaliveModelNamePatched) {\n const patched = new Set<object>();\n // Create one instance of each core type to capture real class prototypes.\n const samples: ZodType[] = [\n z.string(), z.number(), z.boolean(), z.bigint(), z.date(),\n z.object({}), z.array(z.string()), z.enum([\"_\"]),\n z.literal(\"_\"), z.null(), z.undefined(), z.any(), z.unknown(),\n z.void(), z.never(), z.nan(), z.record(z.string(), z.string()),\n z.union([z.string(), z.number()]), z.intersection(z.string(), z.string()),\n z.tuple([z.string()]), z.promise(z.string()), z.custom(),\n z.coerce.string(), z.coerce.number(), z.coerce.boolean(),\n z.coerce.bigint(), z.coerce.date(),\n z.string().optional(), z.string().nullable(), z.string().default(\"\"),\n z.string().pipe(z.string()), z.string().transform(() => \"\"),\n ];\n for (const inst of samples) {\n const proto = Object.getPrototypeOf(inst);\n if (patched.has(proto)) continue;\n patched.add(proto);\n const metaDesc = Object.getOwnPropertyDescriptor(proto, \"meta\");\n if (!metaDesc || !metaDesc.get) continue;\n if ((proto as any).modelName) continue;\n Object.defineProperty(proto, \"modelName\", {\n value: function modelName(name: string) {\n return this.meta({ __genType: name });\n },\n writable: true,\n configurable: true,\n });\n }\n (globalThis as any).__supaliveModelNamePatched = true;\n (globalThis as any).__supalivePatchedCount = patched.size;\n}\n\n// ─── Context Types ───────────────────────────────────────────────────────────\n\n/**\n * Query context passed to query handlers.\n * Contains database reader and user-defined server context.\n */\nexport interface QueryCtx<TContext = unknown> {\n /** Database reader for queries */\n db: DbReader;\n /** User-defined server context (auth, requestId, etc.) */\n serverCtx?: TContext;\n}\n\n/**\n * Mutation context passed to mutation handlers.\n * Contains database writer and user-defined server context.\n */\nexport interface MutationCtx<TContext = unknown> {\n /** Database writer for mutations (includes insert/update/delete) */\n db: DbWriter;\n /** User-defined server context (auth, requestId, etc.) */\n serverCtx?: TContext;\n}\n\n/**\n * Action context passed to action handlers.\n *\n * Actions are the \"external I/O\" tier: they hold the full {@link SupaliveDb}\n * (queries + mutations) and are the ONLY context that also carries side-effect\n * services — {@link ObjectStorage} for uploads/downloads and a {@link JobClient}\n * for scheduling precise one-shots. Queries/mutations stay pure (db only) so\n * they remain cacheable and transaction-scoped.\n */\nexport interface ActionCtx<TContext = unknown> {\n /** Full database interface for queries and mutations */\n db: SupaliveDb;\n /** Object storage, when the server was configured with one (see\n * `SupaliveServerConfig.storage`); `undefined` otherwise. The usual home\n * for upload/download presigning. */\n storage: ObjectStorage;\n /** Job scheduler client for enqueueing precise one-shots, when the server\n * was configured with a `scheduler`; `undefined` otherwise. Scheduling is\n * network I/O, so it belongs in actions, never inside a DB transaction. */\n scheduler: JobClient;\n /** User-defined server context (auth, requestId, etc.) */\n serverCtx?: TContext;\n}\n\n/**\n * Job context passed to job handlers. Structurally identical to\n * {@link ActionCtx}: a job is a server-only procedure that runs\n * non-transactionally against the full {@link SupaliveDb} and may perform\n * external work, but it is triggered by the scheduler over HTTP (a cron tick\n * or a precise one-shot) rather than by a connected client. `serverCtx` is\n * the system context built by the server's `jobContext` factory.\n */\nexport interface JobCtx<TContext = unknown> {\n /** Full database interface for queries and mutations */\n db: SupaliveDb;\n /** System server context built by the server for scheduler-triggered runs */\n serverCtx?: TContext;\n}\n\n/**\n * Context handed to `caller.<proc>.runQuery` / `.runMutation` when invoking one\n * procedure from inside another. Pass the caller handler's own `ctx` — its `db`\n * carries the parent's live transaction (a {@link DbReader}/{@link DbWriter}) or,\n * inside an action, the full {@link SupaliveDb}. The caller uses this to decide\n * whether the nested call joins the parent's snapshot (queries) or runs as an\n * independent sub-transaction (mutations).\n */\nexport interface ParentCtx<TContext = unknown> {\n db: DbReader | DbWriter | SupaliveDb;\n serverCtx?: TContext | undefined;\n}\n\n// ─── Procedure Types ─────────────────────────────────────────────────────────\n\nexport type QueryFn<TInput, TResult, TContext = unknown> = (\n ctx: QueryCtx<TContext>,\n input: TInput,\n) => Promise<TResult>;\n\nexport type MutationFn<TInput, TResult, TContext = unknown> = (\n ctx: MutationCtx<TContext>,\n input: TInput,\n) => Promise<TResult>;\n\nexport type ActionFn<TInput, TResult, TContext = unknown> = (\n ctx: ActionCtx<TContext>,\n input: TInput,\n) => Promise<TResult>;\n\nexport type JobFn<TInput, TResult, TContext = unknown> = (\n ctx: JobCtx<TContext>,\n input: TInput,\n) => Promise<TResult>;\n\n/**\n * Per-procedure override for the cache/subscription segmentation key.\n *\n * omitted | undefined → fall back to `config.getUserId(serverCtx)` (default)\n * false → no identity in hash; cache/sub shared across all users\n * string → a static identity literal (e.g. \"public\" or a tenant id)\n * function → compute from serverCtx + input (sync)\n *\n * When the result of a query is identical regardless of who calls it, set\n * this to a literal (or `false`) so a single cache entry serves everyone.\n *\n * The function form intentionally takes `serverCtx` (not the full `QueryCtx`)\n * because identity is resolved before any DB read is issued.\n */\nexport type QueryIdentitySpec<TInput, TContext> =\n | false\n | string\n | ((serverCtx: TContext, input: TInput) => string | null | undefined);\n\nexport interface BaseProcedure<\n TInput, TResult,\n TType extends \"query\" | \"mutation\" | \"action\" | \"job\",\n TContext = unknown,\n TInternal extends boolean = boolean\n> {\n readonly _type: \"procedure\";\n readonly procedureType: TType;\n readonly inputSchema: ZodType<TInput>;\n readonly outputSchema?: ZodType<any>;\n readonly fn: QueryFn<TInput, TResult, TContext> | MutationFn<TInput, TResult, TContext> | ActionFn<TInput, TResult, TContext> | JobFn<TInput, TResult, TContext>;\n readonly internal: TInternal;\n}\n\nexport interface QueryProcedure<\n TInput, TResult,\n TContext = unknown,\n TInternal extends boolean = boolean\n> extends BaseProcedure<TInput, TResult, \"query\", TContext, TInternal> {\n readonly procedureType: \"query\";\n readonly fn: QueryFn<TInput, TResult, TContext>;\n readonly queryIdentity?: QueryIdentitySpec<TInput, TContext>;\n}\n\nexport interface MutationProcedure<\n TInput, TResult,\n TContext = unknown,\n TInternal extends boolean = boolean\n> extends BaseProcedure<TInput, TResult, \"mutation\", TContext, TInternal> {\n readonly procedureType: \"mutation\";\n readonly fn: MutationFn<TInput, TResult, TContext>;\n}\n\nexport interface ActionProcedure<\n TInput, TResult,\n TContext = unknown,\n TInternal extends boolean = boolean\n> extends BaseProcedure<TInput, TResult, \"action\", TContext, TInternal> {\n readonly procedureType: \"action\";\n readonly fn: ActionFn<TInput, TResult, TContext>;\n}\n\n/**\n * A scheduler-triggered, server-only procedure. Runs like an action (full\n * db, non-transactional, may do external work) but is dispatched by the\n * server's HTTP job endpoint on a cron tick or a precise one-shot rather\n * than over the client WebSocket. Always {@link internal}: true, so it is\n * never reachable via `call`/`subscribe`.\n */\nexport interface JobProcedure<\n TInput, TResult,\n TContext = unknown,\n> extends BaseProcedure<TInput, TResult, \"job\", TContext, true> {\n readonly procedureType: \"job\";\n readonly fn: JobFn<TInput, TResult, TContext>;\n /**\n * Cron expression for a recurring job (e.g. `\"0 3 * * *\"`). Declared crons\n * are synced to the scheduler at server startup. Omit for a job that is\n * only ever invoked as a precise one-shot via the scheduler API.\n */\n readonly cron?: string;\n}\n\nexport type AnyProcedure<TContext = unknown> =\n | QueryProcedure<any, any, TContext>\n | MutationProcedure<any, any, TContext>\n | ActionProcedure<any, any, TContext>\n | JobProcedure<any, any, TContext>;\n\n// ─── Procedure Configuration Types ───────────────────────────────────────────\n\nexport interface QueryConfig<TInput, TResult, TContext = unknown> {\n /** Zod schema for input validation */\n args: ZodType<TInput>;\n /** The query handler function */\n handler: QueryFn<TInput, TResult, TContext>;\n /** Mark as internal (server-only). Default: false */\n internal?: boolean;\n /**\n * Optional Zod schema describing return-type overrides for codegen.\n * Only the fields you specify are overridden; everything else is inferred\n * from the handler's TypeScript return type. Use `.modelName(\"Name\")`\n * on a Zod object to rename the generated model class.\n */\n returns?: ZodType<any>;\n /**\n * Override the cache/subscription segmentation key for this procedure.\n * See {@link QueryIdentitySpec}. Omit to keep the default (per-user) behavior.\n */\n queryIdentity?: QueryIdentitySpec<TInput, TContext>;\n}\n\nexport interface MutationConfig<TInput, TResult, TContext = unknown> {\n /** Zod schema for input validation */\n args: ZodType<TInput>;\n /** The mutation handler function */\n handler: MutationFn<TInput, TResult, TContext>;\n /** Mark as internal (server-only). Default: false */\n internal?: boolean;\n /**\n * Optional Zod schema describing return-type overrides for codegen.\n * Only the fields you specify are overridden; everything else is inferred\n * from the handler's TypeScript return type.\n */\n returns?: ZodType<any>;\n}\n\nexport interface ActionConfig<TInput, TResult, TContext = unknown> {\n /** Zod schema for input validation */\n args: ZodType<TInput>;\n /** The action handler function */\n handler: ActionFn<TInput, TResult, TContext>;\n /** Mark as internal (server-only). Default: false */\n internal?: boolean;\n /**\n * Optional Zod schema describing return-type overrides for codegen.\n * Only the fields you specify are overridden; everything else is inferred\n * from the handler's TypeScript return type.\n */\n returns?: ZodType<any>;\n}\n\nexport interface JobConfig<TInput, TResult, TContext = unknown> {\n /** Zod schema for the job payload */\n args: ZodType<TInput>;\n /** The job handler function */\n handler: JobFn<TInput, TResult, TContext>;\n /**\n * Cron expression for a recurring schedule (e.g. `\"0 3 * * *\"`). Omit for a\n * job that is only invoked as a precise one-shot.\n */\n cron?: string;\n}\n\n/** Extract input type from a procedure */\nexport type InputOf<T> = T extends BaseProcedure<infer I, any, any, any> ? I : never;\n\n/** Extract output type from a procedure */\nexport type OutputOf<T> = T extends BaseProcedure<any, infer O, any, any> ? O : never;\n\n/** Extract procedure type (query/mutation) */\nexport type TypeOf<T> = T extends BaseProcedure<any, any, infer Type, any> ? Type : never;\n\n/** Extract server context type from a procedure */\nexport type ContextOf<T> = T extends BaseProcedure<any, any, any, infer C> ? C : never;\n\n/**\n * Create a query builder with a pre-defined context type.\n * This allows you to define the context type once and have it inferred\n * automatically in all your query handlers.\n * \n * @example\n * // Define your server context\n * interface ServerContext {\n * auth: { userId: string };\n * requestId: string;\n * }\n * \n * // Create a typed query builder\n * const query = createQueryBuilder<ServerContext>();\n * \n * // Use it - context type is automatically inferred!\n * const getUser = query({\n * args: z.object({ id: z.string() }),\n * handler: async (ctx, { id }) => {\n * // ctx.db for database queries\n * const user = await ctx.db.query(UsersSchema).find(id);\n * // ctx.context for server context\n * console.log(ctx.context.requestId);\n * return user;\n * }\n * });\n */\nexport function createQueryBuilder<TContext = unknown>() {\n return function query<TInput, TResult, const TInternal extends boolean = false>(\n config: QueryConfig<TInput, TResult, TContext> & { internal?: TInternal }\n ): QueryProcedure<TInput, TResult, TContext, TInternal> {\n return {\n _type: \"procedure\",\n procedureType: \"query\",\n inputSchema: config.args,\n outputSchema: config.returns,\n fn: config.handler,\n internal: (config.internal ?? false) as TInternal,\n queryIdentity: config.queryIdentity,\n };\n };\n}\n\n// ─── Mutation Builder Factory ────────────────────────────────────────────────\n\n/**\n * Create a mutation builder with a pre-defined context type.\n * This allows you to define the context type once and have it inferred\n * automatically in all your mutation handlers.\n * \n * @example\n * // Define your server context\n * interface ServerContext {\n * auth: { userId: string };\n * requestId: string;\n * }\n * \n * // Create a typed mutation builder\n * const mutation = createMutationBuilder<ServerContext>();\n * \n * // Use it - context type is automatically inferred!\n * const createUser = mutation({\n * args: z.object({ name: z.string() }),\n * handler: async (ctx, { name }) => {\n * // ctx.db for mutations\n * await ctx.db.insert(UsersSchema, id, { name });\n * // ctx.context for server context\n * console.log(ctx.context.requestId);\n * return { success: true };\n * }\n * });\n */\nexport function createMutationBuilder<TContext = unknown>() {\n return function mutation<TInput, TResult, const TInternal extends boolean = false>(\n config: MutationConfig<TInput, TResult, TContext> & { internal?: TInternal }\n ): MutationProcedure<TInput, TResult, TContext, TInternal> {\n return {\n _type: \"procedure\",\n procedureType: \"mutation\",\n inputSchema: config.args,\n outputSchema: config.returns,\n fn: config.handler,\n internal: (config.internal ?? false) as TInternal,\n };\n };\n}\n\n// ─── Action Builder Factory ──────────────────────────────────────────────────\n\n/**\n * Create an action builder with a pre-defined context type.\n * Actions have access to the full SupaliveDb for both queries and mutations.\n *\n * @example\n * // Define your server context\n * interface ServerContext {\n * auth: { userId: string };\n * requestId: string;\n * }\n *\n * // Create a typed action builder\n * const action = createActionBuilder<ServerContext>();\n *\n * // Use it - context type is automatically inferred!\n * const processOrder = action({\n * args: z.object({ orderId: z.string() }),\n * handler: async (ctx, { orderId }) => {\n * // ctx.db for full database access\n * const order = await ctx.db.query(async (db) => {\n * return db.query(OrdersSchema).find(orderId);\n * });\n * await ctx.db.mutation(async (db) => {\n * await db.update(OrdersSchema, orderId, { status: \"processed\" });\n * });\n * // ctx.context for server context\n * console.log(ctx.context.requestId);\n * return { success: true };\n * }\n * });\n */\nexport function createActionBuilder<TContext = unknown>() {\n return function action<TInput, TResult, const TInternal extends boolean = false>(\n config: ActionConfig<TInput, TResult, TContext> & { internal?: TInternal }\n ): ActionProcedure<TInput, TResult, TContext, TInternal> {\n return {\n _type: \"procedure\",\n procedureType: \"action\",\n inputSchema: config.args,\n outputSchema: config.returns,\n fn: config.handler,\n internal: (config.internal ?? false) as TInternal,\n };\n };\n}\n\n// ─── Job Builder Factory ─────────────────────────────────────────────────────\n\n/**\n * Create a job builder with a pre-defined context type. A job is a\n * server-only procedure invoked by the scheduler over HTTP — either on its\n * declared `cron` schedule or as a precise one-shot enqueued via the\n * server's job API. Jobs run like actions (full db, non-transactional) and\n * are always internal, so they are never reachable from a client.\n *\n * @example\n * const job = createJobBuilder<ServerContext>();\n *\n * export const cleanupOtps = job({\n * cron: \"0 * * * *\", // hourly\n * args: z.object({}),\n * handler: async (ctx) => {\n * await ctx.db.mutation(async (db) => { ... });\n * return { ok: true };\n * },\n * });\n */\nexport function createJobBuilder<TContext = unknown>() {\n return function job<TInput, TResult>(\n config: JobConfig<TInput, TResult, TContext>\n ): JobProcedure<TInput, TResult, TContext> {\n return {\n _type: \"procedure\",\n procedureType: \"job\",\n inputSchema: config.args,\n fn: config.handler,\n internal: true,\n cron: config.cron,\n };\n };\n}"],"mappings":";;AAcA,IAAI,CAAE,WAAmB,4BAA4B;CACnD,MAAM,0BAAU,IAAI,IAAY;CAEhC,MAAM,UAAqB;EACzBA,IAAE,OAAO;EAAGA,IAAE,OAAO;EAAGA,IAAE,QAAQ;EAAGA,IAAE,OAAO;EAAGA,IAAE,KAAK;EACxDA,IAAE,OAAO,CAAC,CAAC;EAAGA,IAAE,MAAMA,IAAE,OAAO,CAAC;EAAGA,IAAE,KAAK,CAAC,GAAG,CAAC;EAC/CA,IAAE,QAAQ,GAAG;EAAGA,IAAE,KAAK;EAAGA,IAAE,UAAU;EAAGA,IAAE,IAAI;EAAGA,IAAE,QAAQ;EAC5DA,IAAE,KAAK;EAAGA,IAAE,MAAM;EAAGA,IAAE,IAAI;EAAGA,IAAE,OAAOA,IAAE,OAAO,GAAGA,IAAE,OAAO,CAAC;EAC7DA,IAAE,MAAM,CAACA,IAAE,OAAO,GAAGA,IAAE,OAAO,CAAC,CAAC;EAAGA,IAAE,aAAaA,IAAE,OAAO,GAAGA,IAAE,OAAO,CAAC;EACxEA,IAAE,MAAM,CAACA,IAAE,OAAO,CAAC,CAAC;EAAGA,IAAE,QAAQA,IAAE,OAAO,CAAC;EAAGA,IAAE,OAAO;EACvDA,IAAE,OAAO,OAAO;EAAGA,IAAE,OAAO,OAAO;EAAGA,IAAE,OAAO,QAAQ;EACvDA,IAAE,OAAO,OAAO;EAAGA,IAAE,OAAO,KAAK;EACjCA,IAAE,OAAO,CAAC,CAAC,SAAS;EAAGA,IAAE,OAAO,CAAC,CAAC,SAAS;EAAGA,IAAE,OAAO,CAAC,CAAC,QAAQ,EAAE;EACnEA,IAAE,OAAO,CAAC,CAAC,KAAKA,IAAE,OAAO,CAAC;EAAGA,IAAE,OAAO,CAAC,CAAC,gBAAgB,EAAE;CAC5D;CACA,KAAK,MAAM,QAAQ,SAAS;EAC1B,MAAM,QAAQ,OAAO,eAAe,IAAI;EACxC,IAAI,QAAQ,IAAI,KAAK,GAAG;EACxB,QAAQ,IAAI,KAAK;EACjB,MAAM,WAAW,OAAO,yBAAyB,OAAO,MAAM;EAC9D,IAAI,CAAC,YAAY,CAAC,SAAS,KAAK;EAChC,IAAK,MAAc,WAAW;EAC9B,OAAO,eAAe,OAAO,aAAa;GACxC,OAAO,SAAS,UAAU,MAAc;IACtC,OAAO,KAAK,KAAK,EAAE,WAAW,KAAK,CAAC;GACtC;GACA,UAAU;GACV,cAAc;EAChB,CAAC;CACH;CACA,WAAoB,6BAA6B;CACjD,WAAoB,yBAAyB,QAAQ;AACvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoSA,SAAgB,qBAAyC;CACvD,OAAO,SAAS,MACd,QACsD;EACtD,OAAO;GACL,OAAO;GACP,eAAe;GACf,aAAa,OAAO;GACpB,cAAc,OAAO;GACrB,IAAI,OAAO;GACX,UAAW,OAAO,YAAY;GAC9B,eAAe,OAAO;EACxB;CACF;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,SAAgB,wBAA4C;CAC1D,OAAO,SAAS,SACd,QACyD;EACzD,OAAO;GACL,OAAO;GACP,eAAe;GACf,aAAa,OAAO;GACpB,cAAc,OAAO;GACrB,IAAI,OAAO;GACX,UAAW,OAAO,YAAY;EAChC;CACF;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,SAAgB,sBAA0C;CACxD,OAAO,SAAS,OACd,QACuD;EACvD,OAAO;GACL,OAAO;GACP,eAAe;GACf,aAAa,OAAO;GACpB,cAAc,OAAO;GACrB,IAAI,OAAO;GACX,UAAW,OAAO,YAAY;EAChC;CACF;AACF;;;;;;;;;;;;;;;;;;;;AAuBA,SAAgB,mBAAuC;CACrD,OAAO,SAAS,IACd,QACyC;EACzC,OAAO;GACL,OAAO;GACP,eAAe;GACf,aAAa,OAAO;GACpB,IAAI,OAAO;GACX,UAAU;GACV,MAAM,OAAO;EACf;CACF;AACF"}
@@ -1,2 +1,2 @@
1
- import { $ as ProcedureNames, $r as WriteOp, Ar as OrPredicateSchema, Br as RangeRead, Bt as SupaliveDb, Cr as LeafPredicateSchema, Ct as QueryFn, Dr as OccAbortError, Er as NO_RETRY, Et as createActionBuilder, Fn as defineSchema, Fr as QueryCacheEntry, G as RPCError, Gn as PooledClient, Gr as RawRangeReadSchema, Gt as QueryDefinition, Hn as DbQueryResult, Hr as RawPointRead, Ht as AnyQueryDef, Ir as QueryCacheEntrySchema, J as ActionProcedures, Jr as ReadEntry, Jt as defineQuery, K as WSClientOptions, Kr as RawReadEntry, Kt as ResultOf, Lr as QueryCacheMetadata, Mn as SchemaDefinition, Mr as PointReadSchema, Nr as Predicate, Or as OccConflictError, Ot as createMutationBuilder, Pn as defineComputedField, Pr as PredicateSchema, Q as MutationProcedures, Qr as WriteEntrySchema, Rr as QueryCacheMetadataSchema, Sn as Model, Sr as LeafPredicate, St as QueryCtx, Tr as MutationResult, Tt as TypeOf, U as ClientPublicState, Ur as RawPointReadSchema, Ut as DefsToMap, Vn as Database, Vr as RangeReadSchema, Vt as sleep, W as HeartbeatOptions, Wr as RawRangeRead, Wt as ParamsOf, Xr as RetryConfig, Xt as DbWriter, Y as AppRouter, Yr as ReadEntrySchema, Yt as DbReader, Zr as WriteEntry, Zt as TxContext, _r as CommitLogEntry, _t as MutationCtx, a as CallOptions, at as router, bn as InferSchema, br as CompareOperatorSchema, bt as OutputOf, c as LiveQueryHandle, ct as ActionFn, d as WSClientMethods, dt as ContextOf, ei as WriteOpSchema, et as PublicProcedures, f as createClient, fn as ColumnCodec, fr as AndPredicate, gn as ComputedFieldConfig, gr as CachedPgMetadataSchema, gt as MutationConfig, hr as CachedPgMetadata, i as createCaller, jn as SchemaColumnsOptions, jr as PointRead, kn as SchemaCodecs, kr as OrPredicate, kt as createQueryBuilder, l as LiveQueryState, lt as ActionProcedure, mr as BigIntSchema, n as CallerFromRouter, ni as normalizeIdToBytes, nt as RegisteredProcedure, o as ClientFromProcedures, ot as ActionConfig, pr as AndPredicateSchema, q as WsClientManager, qn as RawClient, qr as RawReadEntrySchema, qt as _resetGlobalDefs, r as CallerOptions, ri as normalizeToBytes, rt as Router, s as ClientOptions, st as ActionCtx, t as CallerFromProcedures, ti as bytesFromJson, tt as QueryProcedures, u as LiveQueryStatus, un as matchesPredicate, ut as AnyProcedure, vr as CommitTs, vt as MutationFn, wr as LiveResult, wt as QueryProcedure, xn as InsertData, xr as DEFAULT_RETRY, xt as QueryConfig, yr as CompareOperator, yt as MutationProcedure, zr as QuerySpec } from "../../index-DgZeS3JK.js";
1
+ import { $ as ProcedureNames, $r as WriteEntry, $t as TxContext, Ar as OccConflictError, Br as QueryCacheMetadataSchema, Cn as InsertData, Cr as DEFAULT_RETRY, Ct as QueryFn, Dr as MutationResult, Er as LiveResult, Et as createActionBuilder, Fr as Predicate, G as RPCError, Gr as RawPointReadSchema, Gt as DefsToMap, Hr as RangeRead, Ht as SupaliveDb, In as defineComputedField, Ir as PredicateSchema, J as ActionProcedures, Jr as RawReadEntry, Jt as ResultOf, K as WSClientOptions, Kr as RawRangeRead, Kt as ParamsOf, Ln as defineSchema, Lr as QueryCacheEntry, Mr as OrPredicateSchema, Nn as SchemaColumnsOptions, Nr as PointRead, Or as NO_RETRY, Ot as createMutationBuilder, Pn as SchemaDefinition, Pr as PointReadSchema, Q as MutationProcedures, Qr as RetryConfig, Qt as DbWriter, Rr as QueryCacheEntrySchema, Sn as InferSchema, Sr as CompareOperatorSchema, St as QueryCtx, Tr as LeafPredicateSchema, Tt as TypeOf, U as ClientPublicState, Un as Database, Ur as RangeReadSchema, Ut as sleep, Vr as QuerySpec, W as HeartbeatOptions, Wn as DbQueryResult, Wr as RawPointRead, Wt as AnyQueryDef, Xr as ReadEntry, Xt as defineQuery, Y as AppRouter, Yn as RawClient, Yr as RawReadEntrySchema, Yt as _resetGlobalDefs, Zr as ReadEntrySchema, Zt as DbReader, _r as CachedPgMetadata, _t as MutationCtx, a as CallOptions, ai as normalizeToBytes, at as router, br as CommitTs, bt as OutputOf, c as LiveQueryHandle, ct as ActionFn, d as WSClientMethods, dt as ContextOf, ei as WriteEntrySchema, et as PublicProcedures, f as createClient, fn as matchesPredicate, gr as BigIntSchema, gt as MutationConfig, hr as AndPredicateSchema, i as createCaller, ii as normalizeIdToBytes, jn as SchemaCodecs, jr as OrPredicate, kr as OccAbortError, kt as createQueryBuilder, l as LiveQueryState, lt as ActionProcedure, mn as ColumnCodec, mr as AndPredicate, n as CallerFromRouter, ni as WriteOpSchema, nt as RegisteredProcedure, o as ClientFromProcedures, ot as ActionConfig, q as WsClientManager, qn as PooledClient, qr as RawRangeReadSchema, qt as QueryDefinition, r as CallerOptions, ri as bytesFromJson, rt as Router, s as ClientOptions, st as ActionCtx, t as CallerFromProcedures, ti as WriteOp, tt as QueryProcedures, u as LiveQueryStatus, ut as AnyProcedure, vn as ComputedFieldConfig, vr as CachedPgMetadataSchema, vt as MutationFn, wn as Model, wr as LeafPredicate, wt as QueryProcedure, xr as CompareOperator, xt as QueryConfig, yr as CommitLogEntry, yt as MutationProcedure, zr as QueryCacheMetadata } from "../../index-BQRlJY_1.js";
2
2
  export { type ActionConfig, type ActionCtx, type ActionFn, type ActionProcedure, type ActionProcedures, AndPredicate, AndPredicateSchema, type AnyProcedure, type AnyQueryDef, type AppRouter, BigIntSchema, CachedPgMetadata, CachedPgMetadataSchema, type CallOptions, CallerFromProcedures, CallerFromRouter, CallerOptions, type ClientFromProcedures, type ClientOptions, type ClientPublicState, type ColumnCodec, CommitLogEntry, CommitTs, CompareOperator, CompareOperatorSchema, type ComputedFieldConfig, type ContextOf, DEFAULT_RETRY, type Database, type DbQueryResult, DbReader, DbReader as ReadContext, DbWriter, DbWriter as WritableContext, type DefsToMap, type HeartbeatOptions, type InferSchema, type InsertData, LeafPredicate, LeafPredicateSchema, type LiveQueryHandle, type LiveQueryState, type LiveQueryStatus, LiveResult, type Model, type MutationConfig, type MutationCtx, type MutationFn, type MutationProcedure, type MutationProcedures, MutationResult, NO_RETRY, OccAbortError, OccConflictError, OrPredicate, OrPredicateSchema, type OutputOf, type ParamsOf, PointRead, PointReadSchema, type PooledClient, Predicate, PredicateSchema, type ProcedureNames, type PublicProcedures, QueryCacheEntry, QueryCacheEntrySchema, QueryCacheMetadata, QueryCacheMetadataSchema, type QueryConfig, type QueryCtx, type QueryDefinition, type QueryFn, type QueryProcedure, type QueryProcedures, QuerySpec, RPCError, RangeRead, RangeReadSchema, type RawClient, RawPointRead, RawPointReadSchema, RawRangeRead, RawRangeReadSchema, RawReadEntry, RawReadEntrySchema, ReadEntry, ReadEntrySchema, type RegisteredProcedure, type ResultOf, RetryConfig, type Router, type SchemaCodecs, type SchemaColumnsOptions, type SchemaDefinition, SupaliveDb, TxContext, type TypeOf, type WSClientMethods, type WSClientOptions, WriteEntry, WriteEntrySchema, WriteOp, WriteOpSchema, WsClientManager, _resetGlobalDefs, bytesFromJson, createActionBuilder, createCaller, createClient, createMutationBuilder, createQueryBuilder, defineComputedField, defineQuery, defineSchema, matchesPredicate, normalizeIdToBytes, normalizeToBytes, router, sleep };
@@ -1,4 +1,4 @@
1
- import { i as createQueryBuilder, r as createMutationBuilder, t as createActionBuilder } from "../../procedure-Ze1GE-N9.js";
1
+ import { i as createQueryBuilder, r as createMutationBuilder, t as createActionBuilder } from "../../procedure-DPgXC2Cm.js";
2
2
  import { n as getContextRegistry, r as router } from "../../router-CiWYeWUR.js";
3
3
  import { o as matchesPredicate } from "../../query-ur-jCtVr.js";
4
4
  import { n as defineSchema, t as defineComputedField } from "../../schema-Dd7u0A1L.js";
@@ -1,2 +1,2 @@
1
- import { t as MySqlDatabase } from "../../mysql-9euRTU3L.js";
1
+ import { t as MySqlDatabase } from "../../mysql-CBSuONm5.js";
2
2
  export { MySqlDatabase };
@@ -1,2 +1,2 @@
1
- import { t as PgDatabase } from "../../postgres-B-OZJdD9.js";
1
+ import { t as PgDatabase } from "../../postgres-BKGLPrKt.js";
2
2
  export { PgDatabase };
@@ -1,3 +1,18 @@
1
- import { $ as ProcedureNames, $t as JsonContainsOptions, An as SchemaColumnMapping, Cn as MutationArgs, Ct as QueryFn, Dn as ReturnLiveQuery, Dt as createJobBuilder, En as QueryArgs, Et as createActionBuilder, Fn as defineSchema, In as schemaRegistry, J as ActionProcedures, Ln as shouldTrackSchema, Mn as SchemaDefinition, Nn as StoredSchemaColumnsOptions, On as ReturnQuery, Ot as createMutationBuilder, Pn as defineComputedField, Q as MutationProcedures, Qt as IdAndCommitTs, Rn as tableNameToId, Sn as Model, St as QueryCtx, Tn as Prettify, Tt as TypeOf, X as ContextRegistry, Y as AppRouter, Z as JobProcedures, _n as DeclarativeIndex, _t as MutationCtx, an as QueryBuilder, at as router, bn as InferSchema, bt as OutputOf, cn as jsonPathExists, ct as ActionFn, dn as ActionArgs, dt as ContextOf, en as JsonHasKeyMultiOptions, et as PublicProcedures, fn as ColumnCodec, ft as JobConfig, gn as ComputedFieldConfig, gt as MutationConfig, hn as ComputedField, ht as JobProcedure, in as PaginationClause, it as getContextRegistry, jn as SchemaColumnsOptions, kn as SchemaCodecs, kt as createQueryBuilder, ln as jsonPathExtract, lt as ActionProcedure, mn as ComputedDataType, mt as JobFn, nn as OrderByOptions, nt as RegisteredProcedure, on as buildPredicateSql, ot as ActionConfig, pn as ComputedCodec, pt as JobCtx, rn as OrderDirection, rt as Router, sn as jsonContains, st as ActionCtx, tn as JsonOpOptions, tt as QueryProcedures, un as matchesPredicate, ut as AnyProcedure, vn as DefineSchemaConfig, vt as MutationFn, wn as OverrideField, wt as QueryProcedure, xn as InsertData, xt as QueryConfig, yn as IndexDefinition, yt as MutationProcedure, zn as trackSchema } from "../../index-DgZeS3JK.js";
1
+ import { $ as ProcedureNames, An as ReturnQuery, At as patchZod$1, Bn as tableNameToId, Cn as InsertData, Ct as QueryFn, Dn as Prettify, Dt as createJobBuilder, En as OverrideField, Et as createActionBuilder, Fn as StoredSchemaColumnsOptions, In as defineComputedField, J as ActionProcedures, Ln as defineSchema, Mn as SchemaColumnMapping, Nn as SchemaColumnsOptions, On as QueryArgs, Ot as createMutationBuilder, Pn as SchemaDefinition, Q as MutationProcedures, Rn as schemaRegistry, Sn as InferSchema, St as QueryCtx, Tn as MutationArgs, Tt as TypeOf, Vn as trackSchema, X as ContextRegistry, Y as AppRouter, Z as JobProcedures, _n as ComputedField, _t as MutationCtx, an as OrderDirection, at as router, bn as DefineSchemaConfig, bt as OutputOf, cn as buildPredicateSql, ct as ActionFn, dn as jsonPathExtract, dt as ContextOf, en as IdAndCommitTs, et as PublicProcedures, fn as matchesPredicate, ft as JobConfig, gn as ComputedDataType, gt as MutationConfig, hn as ComputedCodec, ht as JobProcedure, in as OrderByOptions, it as getContextRegistry, jn as SchemaCodecs, jt as z$1, kn as ReturnLiveQuery, kt as createQueryBuilder, ln as jsonContains, lt as ActionProcedure, mn as ColumnCodec, mt as JobFn, nn as JsonHasKeyMultiOptions, nt as RegisteredProcedure, on as PaginationClause, ot as ActionConfig, pn as ActionArgs, pt as JobCtx, rn as JsonOpOptions, rt as Router, sn as QueryBuilder, st as ActionCtx, tn as JsonContainsOptions, tt as QueryProcedures, un as jsonPathExists, ut as AnyProcedure, vn as ComputedFieldConfig, vt as MutationFn, wn as Model, wt as QueryProcedure, xn as IndexDefinition, xt as QueryConfig, yn as DeclarativeIndex, yt as MutationProcedure, zn as shouldTrackSchema } from "../../index-BQRlJY_1.js";
2
2
  import { n as stableStringify, r as supaliveStringify, t as groupByToMap } from "../../helper-CiacMqje.js";
3
- export { ActionArgs, type ActionConfig, type ActionCtx, type ActionFn, type ActionProcedure, type ActionProcedures, type AnyProcedure, type AppRouter, ColumnCodec, ComputedCodec, ComputedDataType, ComputedField, ComputedFieldConfig, type ContextOf, ContextRegistry, DeclarativeIndex, DefineSchemaConfig, IdAndCommitTs, IndexDefinition, InferSchema, InsertData, type JobConfig, type JobCtx, type JobFn, type JobProcedure, type JobProcedures, JsonContainsOptions, JsonHasKeyMultiOptions, JsonOpOptions, Model, MutationArgs, type MutationConfig, type MutationCtx, type MutationFn, type MutationProcedure, type MutationProcedures, OrderByOptions, OrderDirection, type OutputOf, OverrideField, PaginationClause, Prettify, type ProcedureNames, type PublicProcedures, QueryArgs, QueryBuilder, type QueryConfig, type QueryCtx, type QueryFn, type QueryProcedure, type QueryProcedures, type RegisteredProcedure, ReturnLiveQuery, ReturnQuery, type Router, SchemaCodecs, SchemaColumnMapping, SchemaColumnsOptions, SchemaDefinition, StoredSchemaColumnsOptions, type TypeOf, buildPredicateSql, createActionBuilder, createJobBuilder, createMutationBuilder, createQueryBuilder, defineComputedField, defineSchema, getContextRegistry, groupByToMap, jsonContains, jsonPathExists, jsonPathExtract, matchesPredicate, router, schemaRegistry, shouldTrackSchema, stableStringify, supaliveStringify, tableNameToId, trackSchema };
3
+
4
+ //#region src/exports/procedure.d.ts
5
+ declare const z: typeof z$1;
6
+ declare const patchZod: typeof patchZod$1;
7
+ declare module "zod" {
8
+ interface ZodType<Output, Input, Internals> {
9
+ /**
10
+ * Rename the generated model class in @supalive codegen output.
11
+ * Purely metadata — has no runtime effect beyond setting `.meta({ __genType: name })`.
12
+ */
13
+ modelName(name: string): this;
14
+ }
15
+ } //# sourceMappingURL=procedure.d.ts.map
16
+ //#endregion
17
+ export { ActionArgs, type ActionConfig, type ActionCtx, type ActionFn, type ActionProcedure, type ActionProcedures, type AnyProcedure, type AppRouter, ColumnCodec, ComputedCodec, ComputedDataType, ComputedField, ComputedFieldConfig, type ContextOf, ContextRegistry, DeclarativeIndex, DefineSchemaConfig, IdAndCommitTs, IndexDefinition, InferSchema, InsertData, type JobConfig, type JobCtx, type JobFn, type JobProcedure, type JobProcedures, JsonContainsOptions, JsonHasKeyMultiOptions, JsonOpOptions, Model, MutationArgs, type MutationConfig, type MutationCtx, type MutationFn, type MutationProcedure, type MutationProcedures, OrderByOptions, OrderDirection, type OutputOf, OverrideField, PaginationClause, Prettify, type ProcedureNames, type PublicProcedures, QueryArgs, QueryBuilder, type QueryConfig, type QueryCtx, type QueryFn, type QueryProcedure, type QueryProcedures, type RegisteredProcedure, ReturnLiveQuery, ReturnQuery, type Router, SchemaCodecs, SchemaColumnMapping, SchemaColumnsOptions, SchemaDefinition, StoredSchemaColumnsOptions, type TypeOf, buildPredicateSql, createActionBuilder, createJobBuilder, createMutationBuilder, createQueryBuilder, defineComputedField, defineSchema, getContextRegistry, groupByToMap, jsonContains, jsonPathExists, jsonPathExtract, matchesPredicate, patchZod, router, schemaRegistry, shouldTrackSchema, stableStringify, supaliveStringify, tableNameToId, trackSchema, z };
18
+ //# sourceMappingURL=procedure.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"procedure.d.ts","names":[],"sources":["../../../src/exports/procedure.ts"],"mappings":";;;;cAOa,CAAA,SAAC,GAAK;AAAA,cACN,QAAA,SAAQ,UAAY;AAAA;EAAA,UAIrB,OAAA;IAJC;;;;IAST,SAAA,CAAU,IAAA;EAAA;AAAA"}
@@ -1,6 +1,12 @@
1
- import { i as createQueryBuilder, n as createJobBuilder, r as createMutationBuilder, t as createActionBuilder } from "../../procedure-Ze1GE-N9.js";
1
+ import { a as patchZod$1, i as createQueryBuilder, n as createJobBuilder, o as z$1, r as createMutationBuilder, t as createActionBuilder } from "../../procedure-DPgXC2Cm.js";
2
2
  import { n as getContextRegistry, r as router, t as ContextRegistry } from "../../router-CiWYeWUR.js";
3
3
  import { a as jsonPathExtract, i as jsonPathExists, n as buildPredicateSql, o as matchesPredicate, r as jsonContains, t as QueryBuilder } from "../../query-ur-jCtVr.js";
4
4
  import { a as tableNameToId, i as shouldTrackSchema, n as defineSchema, o as trackSchema, r as schemaRegistry, t as defineComputedField } from "../../schema-Dd7u0A1L.js";
5
5
  import { n as stableStringify, r as supaliveStringify, t as groupByToMap } from "../../helper-wGbzz6zo.js";
6
- export { ContextRegistry, QueryBuilder, buildPredicateSql, createActionBuilder, createJobBuilder, createMutationBuilder, createQueryBuilder, defineComputedField, defineSchema, getContextRegistry, groupByToMap, jsonContains, jsonPathExists, jsonPathExtract, matchesPredicate, router, schemaRegistry, shouldTrackSchema, stableStringify, supaliveStringify, tableNameToId, trackSchema };
6
+ //#region src/exports/procedure.ts
7
+ const z = z$1;
8
+ const patchZod = patchZod$1;
9
+ //#endregion
10
+ export { ContextRegistry, QueryBuilder, buildPredicateSql, createActionBuilder, createJobBuilder, createMutationBuilder, createQueryBuilder, defineComputedField, defineSchema, getContextRegistry, groupByToMap, jsonContains, jsonPathExists, jsonPathExtract, matchesPredicate, patchZod, router, schemaRegistry, shouldTrackSchema, stableStringify, supaliveStringify, tableNameToId, trackSchema, z };
11
+
12
+ //# sourceMappingURL=procedure.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"procedure.js","names":["_z","_patchZod"],"sources":["../../../src/exports/procedure.ts"],"sourcesContent":["export * from \"../router/index\";\nexport * from \"../db/query\";\nexport * from \"../db/schema\";\nexport * from \"../helper\";\n\n// Re-export z (with .modelName() already patched at import time)\nimport { z as _z, patchZod as _patchZod } from \"../router/procedure\";\nexport const z = _z;\nexport const patchZod = _patchZod;\n\n// eslint-disable-next-line @typescript-eslint/no-namespace\ndeclare module \"zod\" {\n interface ZodType<Output, Input, Internals> {\n /**\n * Rename the generated model class in @supalive codegen output.\n * Purely metadata — has no runtime effect beyond setting `.meta({ __genType: name })`.\n */\n modelName(name: string): this;\n }\n}"],"mappings":";;;;;;AAOA,MAAa,IAAIA;AACjB,MAAa,WAAWC"}
@@ -1,4 +1,4 @@
1
- import { In as schemaRegistry, Mn as SchemaDefinition, zn as trackSchema } from "../../index-DgZeS3JK.js";
1
+ import { Pn as SchemaDefinition, Rn as schemaRegistry, Vn as trackSchema } from "../../index-BQRlJY_1.js";
2
2
 
3
3
  //#region src/db/schema-sql.d.ts
4
4
  type SqlDialect = "postgres" | "mysql";