@supalive/core 0.1.6 → 1.0.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 (36) hide show
  1. package/dist/index-DouKwYL6.d.ts +1754 -0
  2. package/dist/index-DouKwYL6.d.ts.map +1 -0
  3. package/dist/mysql-Bxurg_PH.d.ts +104 -0
  4. package/dist/mysql-Bxurg_PH.d.ts.map +1 -0
  5. package/dist/postgres-CfT_aDx3.d.ts +108 -0
  6. package/dist/postgres-CfT_aDx3.d.ts.map +1 -0
  7. package/dist/procedure-DX87tyef.js.map +1 -1
  8. package/dist/router-DlTYWpop.js.map +1 -1
  9. package/dist/src/client/index.d.ts +1 -1
  10. package/dist/src/exports/codegen.d.ts +38 -0
  11. package/dist/src/exports/codegen.d.ts.map +1 -0
  12. package/dist/src/exports/codegen.js +134 -0
  13. package/dist/src/exports/codegen.js.map +1 -0
  14. package/dist/src/exports/mysql.d.ts +1 -1
  15. package/dist/src/exports/postgres.d.ts +1 -1
  16. package/dist/src/exports/procedure.d.ts +1 -1
  17. package/dist/src/exports/schema-sql.d.ts +1 -1
  18. package/dist/src/exports/server.d.ts +4 -4
  19. package/dist/src/exports/server.d.ts.map +1 -1
  20. package/dist/src/exports/server.js +2 -7
  21. package/dist/src/exports/server.js.map +1 -1
  22. package/dist/src/exports/subscription-manager-worker-entry.js +1 -2
  23. package/dist/src/exports/subscription-manager-worker-entry.js.map +1 -1
  24. package/dist/src/exports/types.d.ts +2 -2
  25. package/dist/subscription-worker-CqoWp6zB.js +511 -0
  26. package/dist/subscription-worker-CqoWp6zB.js.map +1 -0
  27. package/dist/subscription-worker-PtmJWEj1.js +511 -0
  28. package/dist/subscription-worker-PtmJWEj1.js.map +1 -0
  29. package/dist/types_server-BW1ys_SK.d.ts +216 -0
  30. package/dist/types_server-BW1ys_SK.d.ts.map +1 -0
  31. package/dist/types_server-Dk6o_B7N.js.map +1 -1
  32. package/dist/types_server-Dpsi0wpG.d.ts +216 -0
  33. package/dist/types_server-Dpsi0wpG.d.ts.map +1 -0
  34. package/dist/types_server-DzrIccyO.d.ts +216 -0
  35. package/dist/types_server-DzrIccyO.d.ts.map +1 -0
  36. package/package.json +3 -2
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-DouKwYL6.d.ts","names":[],"sources":["../src/db/types_db.ts","../src/server/subscription-manager-types.ts","../src/db/cache.ts","../src/db/db.ts","../src/db/schema.ts","../src/db/query.ts","../src/db/context.ts","../src/db/query_definition.ts","../src/db/realtime_db.ts","../src/router/procedure.ts","../src/router/router.ts","../src/client/ws_client_manager.ts","../src/db/types_client_rpc.ts","../src/client/client.ts","../src/client/caller_client.ts"],"mappings":";;;;;;;KAIY,QAAA;AAAA,cAEC,YAAA,EAAY,CAAA,CAAA,OAAA,CAAA,CAAA,CAAA,SAAA,EAAA,CAAA,CAAA,YAAA;AAAA,cAEZ,qBAAA,EAAqB,CAAA,CAAA,OAAA;;;;;;;;;;;;;;;;;;;KAOtB,eAAA,GAAkB,CAAA,CAAE,KAAK,QAAQ,qBAAA;AAAA,KAGjC,SAAA,GACR,aAAA;EACE,IAAA;EAAa,QAAA,EAAU,SAAA;AAAA;EACvB,IAAA;EAAY,QAAA,EAAU,SAAA;AAAA;AAAA,cACf,eAAA,EAAiB,CAAA,CAAE,OAAO,CAAC,SAAA;AAAA,cAQ3B,mBAAA,EAAmB,CAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAmBpB,aAAA,GAAgB,CAAA,CAAE,KAAK,QAAQ,mBAAA;AAAA,cAE9B,kBAAA,EAAkB,CAAA,CAAA,SAAA;;;;KAInB,YAAA,GAAe,CAAA,CAAE,KAAK,QAAQ,kBAAA;AAAA,cAE7B,iBAAA,EAAiB,CAAA,CAAA,SAAA;;;;KAIlB,WAAA,GAAc,CAAA,CAAE,KAAK,QAAQ,iBAAA;;KAG7B,SAAA,GAAY,SAAS;AAAA,iBAOjB,kBAAA,CAAmB,EAAA,mBA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,EAAW,QAAA,KAAa,OAAA,CAAQ,QAAA,CAAS,WAAA,CAAY,CAAA;AAAA,IAChG,WAAA,CAAY,CAAA;EAAa,aAAA;AAAA;EACvB,MAAA,GAAS,KAAA,EAAO,OAAA,CAAQ,WAAA,CAAY,CAAA,IAAK,SAAA,EAAW,QAAA,KAAa,OAAA,CAAQ,QAAA,CAAS,WAAA,CAAY,CAAA;AAAA;EAGlG,IAAA,GAAO,MAAA;IAAU,EAAA,EAAI,UAAA;EAAA,MAAiB,OAAA;AAAA;;;;KAM9B,gBAAA,iBAAiC,MAAA,cAAoB,oBAAA,CAAqB,OAAA"}
@@ -0,0 +1,104 @@
1
+ import { An as CacheLayer, Cn as DbType, En as PreparedQueries, On as SqlBuilder, Or as ReadEntry, Sn as DbQueryResult, Tn as PooledClient, Zn as CommitLogEntry, jr as WriteEntry, kn as TxDatabase, wn as LazyCommitTsParam, xn as Database } from "./index-DouKwYL6.js";
2
+ import { Pool, PoolOptions } from "mysql2/promise";
3
+ import { Logger } from "pino";
4
+
5
+ //#region src/db/mysql.d.ts
6
+ /**
7
+ * mysql2's PoolOptions does not have a per-statement timeout field; we
8
+ * carry our own. Set 0 to disable.
9
+ */
10
+ type MySqlPoolOptions = PoolOptions & {
11
+ queryTimeoutMs?: number;
12
+ };
13
+ declare class MySqlDatabase implements Database {
14
+ constructor(logger: Logger, config: MySqlPoolOptions, pool?: Pool | undefined);
15
+ private logger;
16
+ config: PoolOptions;
17
+ protected queryTimeoutMs: number;
18
+ private pool;
19
+ readonly dbType: DbType;
20
+ readonly sqlBuilder: SqlBuilder;
21
+ columnTypes: Map<string, Map<string, string>>;
22
+ protected sqlCache: Map<string, string>;
23
+ /**
24
+ * Fetches actual column types from MySQL for `table` and returns a
25
+ * map of DB column name → MySQL type string (as produced by `COLUMN_TYPE`,
26
+ * e.g. `bigint`, `integer`, `varchar(32)`, `text`, `json`).
27
+ * No caching here — see {@link getColumnTypes} for the cached path.
28
+ */
29
+ loadColumnTypesFromMySql(table: string): Promise<Map<string, string>>;
30
+ /**
31
+ * Synchronous column-type lookup. The apply path calls this on every
32
+ * batched write, so it can't await — populate the cache via
33
+ * {@link bootstrapColumnTypes} at server start. Throws if `table` is
34
+ * missing (programmer error / bootstrap skipped).
35
+ */
36
+ getColumnTypes(table: string): Map<string, string> | null;
37
+ /**
38
+ * Eagerly load column types into the in-memory cache. With a Redis
39
+ * client supplied, attempts the cache key first and falls through to
40
+ * MySQL on miss (writing the result back to Redis). This is the
41
+ * "one server queries MySQL, the rest read from Redis" pattern for cold
42
+ * starts in a multi-instance deploy. Without Redis, always queries MySQL.
43
+ *
44
+ * Pass `tables` to limit the load to a specific list; otherwise every
45
+ * user table in the connected database is loaded.
46
+ *
47
+ * The Redis cache key should encode whatever invalidates types in your
48
+ * environment (typically a schema version / deploy version). The
49
+ * subscriber in supalive-server.ts is expected to publish a reload
50
+ * signal after migrations and invoke {@link invalidateColumnTypes}.
51
+ */
52
+ bootstrapColumnTypes(opts: {
53
+ redis?: CacheLayer;
54
+ cacheKey: string;
55
+ tables?: string[];
56
+ }): Promise<void>;
57
+ /**
58
+ * Invalidate cached types (and dependent SQL) for `table`, or the entire
59
+ * cache if `table` is omitted. The Redis-pubsub reload signal in
60
+ * supalive-server.ts is expected to call this on schema changes.
61
+ */
62
+ invalidateColumnTypes(table?: string): void;
63
+ /** Replace this instance's caches with shared references from a parent.
64
+ * Used by getTransactionClient so types loaded once at startup are
65
+ * visible inside transactions. */
66
+ adoptCaches(columnTypes: Map<string, Map<string, string>>, sqlCache: Map<string, string>): void;
67
+ /** Enumerate the user-defined tables in the connected database for mysql — used
68
+ * by bootstrapColumnTypes() when no explicit list is provided. */
69
+ private listUserTables;
70
+ migrationSql: string[];
71
+ query<T = any>(sql: string, params?: unknown[]): Promise<DbQueryResult<T>>;
72
+ getClient(): Promise<PooledClient>;
73
+ getTransactionClient(): Promise<TxDatabase>;
74
+ getLatestSnapshotTimestamp(): Promise<bigint>;
75
+ updateLatestSnapshotTimestamp(commitTs: bigint): Promise<void>;
76
+ getNextTimestamp(): Promise<bigint>;
77
+ attachPrevDataToWriteSet(writeSet: WriteEntry[], readSet: ReadEntry[]): Promise<void>;
78
+ prepareCommitWrites(readSet: ReadEntry[], writeSet: WriteEntry[], commitTs: LazyCommitTsParam): Promise<PreparedQueries>;
79
+ private mysqlPrepareBatchWrites;
80
+ private mysqlPrepareInsertBatch;
81
+ private mysqlPrepareUpdateSingle;
82
+ private mysqlPrepareDeleteBatch;
83
+ private mysqlPrepareCommitLogs;
84
+ /**
85
+ * Point-only OCC check. For each genuine point read, compare the row's
86
+ * current commit_ts against the value captured at read time. A `null`
87
+ * expectedCommitTs means "row didn't exist when we read"; any row found
88
+ * now is a conflict. Reads whose row is being written in this same txn
89
+ * are skipped — the CAS UPDATE/DELETE already validated those.
90
+ */
91
+ private mysqlPrepareValidatePointReadsByCommitTs;
92
+ commitWrites(beginTs: bigint, queries: PreparedQueries, commitTs: bigint): Promise<{
93
+ success: boolean;
94
+ }>;
95
+ private mysqlApplyWrites;
96
+ private validatePointReadsByCommitTs;
97
+ pruneCommitLogsBefore(ts: bigint): Promise<bigint>;
98
+ getCommitLogsBetweenTs(beginTs: bigint, endTs: bigint, tableIds: Uint8Array[]): Promise<CommitLogEntry[]>;
99
+ getCommitLogsSinceTs(sinceTs: bigint, excludeTs: bigint, tableIds: Uint8Array[]): Promise<CommitLogEntry[]>;
100
+ close(): Promise<void>;
101
+ }
102
+ //#endregion
103
+ export { MySqlDatabase as t };
104
+ //# sourceMappingURL=mysql-Bxurg_PH.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mysql-Bxurg_PH.d.ts","names":[],"sources":["../src/db/mysql.ts"],"mappings":";;;;;;;;;KAwCY,gBAAA,GAAmB,WAAW;EAAK,cAAc;AAAA;AAAA,cAEhD,aAAA,YAAyB,QAAA;cAElC,MAAA,EAAQ,MAAA,EACR,MAAA,EAAQ,gBAAA,EACR,IAAA,GAAM,IAAA;EAAA,QAaA,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OAAA;IAAU,OAAA;EAAA;EAAA,QAqCC,gBAAA;EAAA,QAyDA,4BAAA;EAwCR,qBAAA,CAAsB,EAAA,WAAa,OAAA;EAQnC,sBAAA,CAAuB,OAAA,UAAiB,KAAA,UAAe,QAAA,EAAU,UAAA,KAAe,OAAA,CAAQ,cAAA;EAmBxF,oBAAA,CAAqB,OAAA,UAAiB,SAAA,UAAmB,QAAA,EAAU,UAAA,KAAe,OAAA,CAAQ,cAAA;EAmB1F,KAAA,IAAS,OAAA;AAAA"}
@@ -0,0 +1,108 @@
1
+ import { An as CacheLayer, Cn as DbType, En as PreparedQueries, On as SqlBuilder, Or as ReadEntry, Sn as DbQueryResult, Tn as PooledClient, Zn as CommitLogEntry, jr as WriteEntry, kn as TxDatabase, wn as LazyCommitTsParam, xn as Database } from "./index-DouKwYL6.js";
2
+ import { Pool, PoolConfig } from "pg";
3
+ import { Logger } from "pino";
4
+
5
+ //#region src/db/postgres.d.ts
6
+ declare class PgDatabase implements Database {
7
+ constructor(logger: Logger, config: PoolConfig, pool?: Pool | undefined);
8
+ private logger;
9
+ config: PoolConfig;
10
+ private pool;
11
+ readonly sqlBuilder: SqlBuilder;
12
+ readonly dbType: DbType;
13
+ columnTypes: Map<string, Map<string, string>>;
14
+ protected sqlCache: Map<string, string>;
15
+ /**
16
+ * Fetches actual column types from Postgres for `table` and returns a
17
+ * map of DB column name → PG type string (as produced by `format_type`,
18
+ * e.g. `bigint`, `integer`, `character varying(32)`, `text[]`, `jsonb`).
19
+ * No caching here — see {@link getColumnTypes} for the cached path.
20
+ */
21
+ loadColumnTypesFromPg(table: string): Promise<Map<string, string>>;
22
+ /**
23
+ * Synchronous column-type lookup. The apply path calls this on every
24
+ * batched write, so it can't await — populate the cache via
25
+ * {@link bootstrapColumnTypes} at server start. Throws if `table` is
26
+ * missing (programmer error / bootstrap skipped).
27
+ */
28
+ getColumnTypes(table: string): Map<string, string> | null;
29
+ /**
30
+ * Eagerly load column types into the in-memory cache. With a Redis
31
+ * client supplied, attempts the cache key first and falls through to
32
+ * Postgres on miss (writing the result back to Redis). This is the
33
+ * "one server queries PG, the rest read from Redis" pattern for cold
34
+ * starts in a multi-instance deploy. Without Redis, always queries PG.
35
+ *
36
+ * Pass `tables` to limit the load to a specific list; otherwise every
37
+ * user table in the connected database is loaded.
38
+ *
39
+ * The Redis cache key should encode whatever invalidates types in your
40
+ * environment (typically a schema version / deploy version). The
41
+ * subscriber in supalive-server.ts is expected to publish a reload
42
+ * signal after migrations and invoke {@link invalidateColumnTypes}.
43
+ */
44
+ bootstrapColumnTypes(opts: {
45
+ redis?: CacheLayer;
46
+ cacheKey: string;
47
+ tables?: string[];
48
+ }): Promise<void>;
49
+ /**
50
+ * Invalidate cached types (and dependent SQL) for `table`, or the entire
51
+ * cache if `table` is omitted. The Redis-pubsub reload signal in
52
+ * supalive-server.ts is expected to call this on schema changes.
53
+ */
54
+ private invalidateColumnTypes;
55
+ /** Enumerate the user-defined tables in the connected database — used
56
+ * by bootstrapColumnTypes() when no explicit list is provided. */
57
+ private listUserTables;
58
+ migrationSql: string[];
59
+ query<T = any>(sql: string, params?: unknown[]): Promise<DbQueryResult<T>>;
60
+ getClient(): Promise<PooledClient>;
61
+ getTransactionClient(): Promise<TxDatabase>;
62
+ /** Internal: replace this instance's caches with shared references from
63
+ * a parent. Used by PgDatabase.getTransactionClient. */
64
+ adoptCaches(columnTypes: Map<string, Map<string, string>>, sqlCache: Map<string, string>): void;
65
+ getLatestSnapshotTimestamp(): Promise<bigint>;
66
+ updateLatestSnapshotTimestamp(commitTs: bigint): Promise<void>;
67
+ getNextTimestamp(): Promise<bigint>;
68
+ attachPrevDataToWriteSet(writeSet: WriteEntry[], readSet: ReadEntry[]): Promise<void>;
69
+ prepareCommitWrites(readSet: ReadEntry[], writeSet: WriteEntry[], commitTs: LazyCommitTsParam): Promise<PreparedQueries>;
70
+ private pgPrepareBatchWrites;
71
+ private pgPrepareInsertSingle;
72
+ private pgPrepareInsertBatch;
73
+ private pgPrepareUpdateSingle;
74
+ private pgPrepareUpdateBatch;
75
+ private pgPrepareDeleteSingle;
76
+ private pgPrepareDeleteBatch;
77
+ private buildOrGetInsertSql;
78
+ private buildOrGetUpdateSql;
79
+ private buildOrGetDeleteSql;
80
+ private pgPrepareCommitLogs;
81
+ /**
82
+ * Point-only OCC check. For each genuine point read, compare the row's
83
+ * current commit_ts against the value captured at read time. A `null`
84
+ * expectedCommitTs means "row didn't exist when we read"; any row found
85
+ * now is a conflict. Reads whose row is being written in this same txn
86
+ * are skipped — the CAS UPDATE/DELETE already validated those.
87
+ */
88
+ private pgPrepareValidatePointReadsByCommitTs;
89
+ commitWrites(beginTs: bigint, queries: PreparedQueries, commitTs: bigint): Promise<{
90
+ success: boolean;
91
+ }>;
92
+ private pgApplyWrites;
93
+ /**
94
+ * Point-only OCC check. For each genuine point read, compare the row's
95
+ * current commit_ts against the value captured at read time. A `null`
96
+ * expectedCommitTs means "row didn't exist when we read"; any row found
97
+ * now is a conflict. Reads whose row is being written in this same txn
98
+ * are skipped — the CAS UPDATE/DELETE already validated those.
99
+ */
100
+ private validatePointReadsByCommitTs;
101
+ pruneCommitLogsBefore(ts: bigint): Promise<bigint>;
102
+ getCommitLogsBetweenTs(beginTs: bigint, endTs: bigint, tableIds: Uint8Array[]): Promise<CommitLogEntry[]>;
103
+ getCommitLogsSinceTs(sinceTs: bigint, excludeTs: bigint, tableIds: Uint8Array[]): Promise<CommitLogEntry[]>;
104
+ close(): Promise<void>;
105
+ }
106
+ //#endregion
107
+ export { PgDatabase as t };
108
+ //# sourceMappingURL=postgres-CfT_aDx3.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-CfT_aDx3.d.ts","names":[],"sources":["../src/db/postgres.ts"],"mappings":";;;;;cAiBa,UAAA,YAAsB,QAAA;cAE/B,MAAA,EAAQ,MAAA,EACR,MAAA,EAAQ,UAAA,EACR,IAAA,GAAM,IAAA;EAAA,QAWA,MAAA;EACD,MAAA,EAAQ,UAAA;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5C,qCAAA;EAkDF,YAAA,CACJ,OAAA,UACA,OAAA,EAAS,eAAA,EACT,QAAA,WACC,OAAA;IAAU,OAAA;EAAA;EAAA,QAqCC,aAAA;EArpBA;;;;;;;EAAA,QAgwBA,4BAAA;EA0CR,qBAAA,CAAsB,EAAA,WAAa,OAAA;EAQnC,sBAAA,CAAuB,OAAA,UAAiB,KAAA,UAAe,QAAA,EAAU,UAAA,KAAe,OAAA,CAAQ,cAAA;EAmBxF,oBAAA,CAAqB,OAAA,UAAiB,SAAA,UAAmB,QAAA,EAAU,UAAA,KAAe,OAAA,CAAQ,cAAA;EAmB1F,KAAA,IAAS,OAAA;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"procedure-DX87tyef.js","names":[],"sources":["../src/router/procedure.ts"],"sourcesContent":["import type { ZodType } from \"zod\";\nimport type { DbReader, DbWriter } from \"../db/context\";\nimport type { SupaliveDb } from \"../db/realtime_db\";\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 * Contains the full SupaliveDb for both queries and mutations, plus user-defined server context.\n */\nexport interface ActionCtx<TContext = unknown> {\n /** Full database interface for queries and mutations */\n db: SupaliveDb;\n /** User-defined server context (auth, requestId, etc.) */\n serverCtx: TContext;\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\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\",\n TContext = unknown,\n TInternal extends boolean = boolean\n> {\n readonly _type: \"procedure\";\n readonly procedureType: TType;\n readonly inputSchema: ZodType<TInput>;\n readonly fn: QueryFn<TInput, TResult, TContext> | MutationFn<TInput, TResult, TContext> | ActionFn<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\nexport type AnyProcedure<TContext = unknown> =\n | QueryProcedure<any, any, TContext>\n | MutationProcedure<any, any, TContext>\n | ActionProcedure<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 * 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\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\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 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 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 fn: config.handler,\n internal: (config.internal ?? false) as TInternal,\n };\n };\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkMA,SAAgB,qBAAyC;CACvD,OAAO,SAAS,MACd,QACsD;EACtD,OAAO;GACL,OAAO;GACP,eAAe;GACf,aAAa,OAAO;GACpB,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,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,IAAI,OAAO;GACX,UAAW,OAAO,YAAY;EAChC;CACF;AACF"}
1
+ {"version":3,"file":"procedure-DX87tyef.js","names":[],"sources":["../src/router/procedure.ts"],"sourcesContent":["import type { ZodType } from \"zod\";\nimport type { DbReader, DbWriter } from \"../db/context\";\nimport type { SupaliveDb } from \"../db/realtime_db\";\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 * Contains the full SupaliveDb for both queries and mutations, plus user-defined server context.\n */\nexport interface ActionCtx<TContext = unknown> {\n /** Full database interface for queries and mutations */\n db: SupaliveDb;\n /** User-defined server context (auth, requestId, etc.) */\n serverCtx?: TContext;\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\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\",\n TContext = unknown,\n TInternal extends boolean = boolean\n> {\n readonly _type: \"procedure\";\n readonly procedureType: TType;\n readonly inputSchema: ZodType<TInput>;\n readonly fn: QueryFn<TInput, TResult, TContext> | MutationFn<TInput, TResult, TContext> | ActionFn<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\nexport type AnyProcedure<TContext = unknown> =\n | QueryProcedure<any, any, TContext>\n | MutationProcedure<any, any, TContext>\n | ActionProcedure<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 * 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\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\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 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 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 fn: config.handler,\n internal: (config.internal ?? false) as TInternal,\n };\n };\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkMA,SAAgB,qBAAyC;CACvD,OAAO,SAAS,MACd,QACsD;EACtD,OAAO;GACL,OAAO;GACP,eAAe;GACf,aAAa,OAAO;GACpB,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,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,IAAI,OAAO;GACX,UAAW,OAAO,YAAY;EAChC;CACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"router-DlTYWpop.js","names":[],"sources":["../src/router/router.ts"],"sourcesContent":["import type { AnyProcedure } from \"./procedure\";\n\n// ─── Router Types ────────────────────────────────────────────────────────────\n\n/**\n * A router maps procedure names (keys) to their definitions.\n * This is the type that's exported from your app and used by the client.\n */\nexport type Router<TProcedures extends Record<string, AnyProcedure<TContext>>, TContext = unknown> = {\n _type: \"router\";\n procedures: TProcedures;\n contextName: string;\n};\n\n/**\n * Inferred AppRouter type from router() call.\n * Captures the full procedure map for client type inference.\n */\nexport type AppRouter<\n TProcedures extends Record<string, AnyProcedure<TContext>> = Record<string, AnyProcedure>,\n TContext = unknown\n> = Router<TProcedures, TContext>;\n\n// ─── Type Helpers for Client ─────────────────────────────────────────────────\n\n/** Get query procedures only from a router */\nexport type QueryProcedures<T extends Record<string, AnyProcedure>> = {\n [K in keyof T as T[K] extends { procedureType: \"query\" } ? K : never]: T[K];\n};\n\n/** Get mutation procedures only from a router */\nexport type MutationProcedures<T extends Record<string, AnyProcedure>> = {\n [K in keyof T as T[K] extends { procedureType: \"mutation\" } ? K : never]: T[K];\n};\n\n/** Get action procedures only from a router */\nexport type ActionProcedures<T extends Record<string, AnyProcedure>> = {\n [K in keyof T as T[K] extends { procedureType: \"action\" } ? K : never]: T[K];\n};\n\n/** Get public (non-internal) procedures - for client type safety */\nexport type PublicProcedures<T extends Record<string, AnyProcedure>> = Pick<\n T,\n { [K in keyof T]: T[K] extends { internal: true } ? never : K }[keyof T]\n>;\n\n/** Extract procedure names from a router */\nexport type ProcedureNames<T extends Router<any>> =\n T extends Router<infer P> ? keyof P : never;\n\nexport type RouterConfig<T> = {\n procedures: T;\n contextName?: string;\n};\n\n/**\n* Create a router from procedure definitions.\n* Procedure names are inferred from the object keys.\n* \n* @example\n* const appRouter = router({\n* procedures: {\n* getUser,\n* createUser,\n* internalGetAll,\n* },\n* });\n* \n* export type AppRouter = typeof appRouter;\n*/\nexport function router<TProcedures extends Record<string, AnyProcedure<any>>, TContext = unknown>(\n config: RouterConfig<TProcedures>,\n): Router<TProcedures, TContext> {\n const registry = getContextRegistry(config.contextName ?? \"default\");\n\n // Register all procedures at router creation time\n for (const [name, proc] of Object.entries(config.procedures)) {\n registry.registerProcedure(name, proc);\n }\n\n\n return {\n _type: \"router\",\n procedures: config.procedures,\n contextName: config.contextName ?? \"default\",\n };\n}\n\nexport interface RegisteredProcedure<TContext = unknown> {\n name: string;\n type: \"query\" | \"mutation\" | \"action\";\n internal: boolean;\n inputSchema: AnyProcedure<TContext>[\"inputSchema\"];\n fn: AnyProcedure<TContext>[\"fn\"];\n /** Only present for `type === \"query\"`. See `QueryIdentitySpec`. */\n queryIdentity?: false | string | ((serverCtx: TContext, input: unknown) => string | null | undefined);\n}\n\n\nconst contextRegistry = new Map<string, ContextRegistry>();\n\nexport function getContextRegistry(inContext: string): ContextRegistry {\n let registry = contextRegistry.get(inContext);\n if (!registry) {\n registry = new ContextRegistry();\n contextRegistry.set(inContext, registry);\n }\n return registry;\n}\n\nexport class ContextRegistry {\n procedureRegistry = new Map<string, RegisteredProcedure<any>>();\n internalProcedureNames = new Set<string>();\n\n registerProcedure<TContext>(name: string, proc: AnyProcedure<TContext>): void {\n if (this.procedureRegistry.has(name)) {\n throw new Error(\n `[router] Procedure \"${name}\" is already registered. ` +\n `Each procedure name must be unique across the application.`\n );\n }\n\n // Track internal procedures by name\n if (proc.internal) {\n this.markInternalProcedure(name);\n }\n\n const queryIdentity =\n proc.procedureType === \"query\"\n ? (proc as { queryIdentity?: RegisteredProcedure<TContext>[\"queryIdentity\"] }).queryIdentity\n : undefined;\n\n this.procedureRegistry.set(name, {\n name,\n type: proc.procedureType,\n internal: proc.internal,\n inputSchema: proc.inputSchema,\n fn: proc.fn,\n queryIdentity,\n });\n }\n\n /** Get a registered procedure by name (runtime lookup) */\n getProcedure<TContext = unknown>(name: string): RegisteredProcedure<TContext> | undefined {\n return this.procedureRegistry.get(name);\n }\n\n /** Get all registered procedure names */\n getProcedureNames(): string[] {\n return [...this.procedureRegistry.keys()];\n }\n\n /** Get all registered procedures */\n getAllProcedures(): Map<string, RegisteredProcedure> {\n return new Map(this.procedureRegistry);\n }\n\n /** Clear the registry (for testing only) */\n clearRegistry(): void {\n this.procedureRegistry.clear();\n this.clearInternalProcedures();\n }\n\n markInternalProcedure(name: string): void {\n this.internalProcedureNames.add(name);\n }\n\n isInternalProcedure(name: string): boolean {\n return this.internalProcedureNames.has(name);\n }\n\n clearInternalProcedures(): void {\n this.internalProcedureNames.clear();\n }\n}"],"mappings":";;;;;;;;;;;;;;;;AAsEA,SAAgB,OACd,QAC+B;CAC/B,MAAM,WAAW,mBAAmB,OAAO,eAAe,SAAS;CAGnE,KAAK,MAAM,CAAC,MAAM,SAAS,OAAO,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":3,"file":"router-DlTYWpop.js","names":[],"sources":["../src/router/router.ts"],"sourcesContent":["import type { AnyProcedure } from \"./procedure\";\n\n// ─── Router Types ────────────────────────────────────────────────────────────\n\n/**\n * A router maps procedure names (keys) to their definitions.\n * This is the type that's exported from your app and used by the client.\n */\nexport type Router<TProcedures extends Record<string, AnyProcedure<TContext>>, TContext = unknown> = {\n _type: \"router\";\n procedures: TProcedures;\n contextName: string;\n};\n\n/**\n * Inferred AppRouter type from router() call.\n * Captures the full procedure map for client type inference.\n */\nexport type AppRouter<\n TProcedures extends Record<string, AnyProcedure<TContext>> = Record<string, AnyProcedure>,\n TContext = unknown\n> = Router<TProcedures, TContext>;\n\n// ─── Type Helpers for Client ─────────────────────────────────────────────────\n\n/** Get query procedures only from a router */\nexport type QueryProcedures<T extends Record<string, AnyProcedure>> = {\n [K in keyof T as T[K] extends { procedureType: \"query\" } ? K : never]: T[K];\n};\n\n/** Get mutation procedures only from a router */\nexport type MutationProcedures<T extends Record<string, AnyProcedure>> = {\n [K in keyof T as T[K] extends { procedureType: \"mutation\" } ? K : never]: T[K];\n};\n\n/** Get action procedures only from a router */\nexport type ActionProcedures<T extends Record<string, AnyProcedure>> = {\n [K in keyof T as T[K] extends { procedureType: \"action\" } ? K : never]: T[K];\n};\n\n/** Get public (non-internal) procedures - for client type safety */\nexport type PublicProcedures<T extends Record<string, AnyProcedure>> = Pick<\n T,\n { [K in keyof T]: T[K] extends { internal: true } ? never : K }[keyof T]\n>;\n\n/** Extract procedure names from a router */\nexport type ProcedureNames<T extends Router<any>> =\n T extends Router<infer P> ? keyof P : never;\n\nexport type RouterConfig<T> = {\n procedures: T;\n contextName?: string;\n};\n\n/**\n* Create a router from procedure definitions.\n* Procedure names are inferred from the object keys.\n* \n* @example\n* const appRouter = router({\n* procedures: {\n* getUser,\n* createUser,\n* internalGetAll,\n* },\n* });\n* \n* export type AppRouter = typeof appRouter;\n*/\nexport function router<TProcedures extends Record<string, AnyProcedure<any>>, TContext = unknown>(\n config: RouterConfig<TProcedures>,\n): Router<TProcedures, TContext> {\n const registry = getContextRegistry(config.contextName ?? \"default\");\n\n // Register all procedures at router creation time\n for (const [name, proc] of Object.entries(config.procedures)) {\n registry.registerProcedure(name, proc);\n }\n\n\n return {\n _type: \"router\",\n procedures: config.procedures,\n contextName: config.contextName ?? \"default\",\n };\n}\n\nexport interface RegisteredProcedure<TContext = unknown> {\n name: string;\n type: \"query\" | \"mutation\" | \"action\";\n internal: boolean;\n inputSchema: AnyProcedure<TContext>[\"inputSchema\"];\n fn: AnyProcedure<TContext>[\"fn\"];\n /** Only present for `type === \"query\"`. See `QueryIdentitySpec`. */\n queryIdentity?: false | string | ((serverCtx: TContext | undefined, input: unknown) => string | null | undefined);\n}\n\n\nconst contextRegistry = new Map<string, ContextRegistry>();\n\nexport function getContextRegistry(inContext: string): ContextRegistry {\n let registry = contextRegistry.get(inContext);\n if (!registry) {\n registry = new ContextRegistry();\n contextRegistry.set(inContext, registry);\n }\n return registry;\n}\n\nexport class ContextRegistry {\n procedureRegistry = new Map<string, RegisteredProcedure<any>>();\n internalProcedureNames = new Set<string>();\n\n registerProcedure<TContext>(name: string, proc: AnyProcedure<TContext>): void {\n if (this.procedureRegistry.has(name)) {\n throw new Error(\n `[router] Procedure \"${name}\" is already registered. ` +\n `Each procedure name must be unique across the application.`\n );\n }\n\n // Track internal procedures by name\n if (proc.internal) {\n this.markInternalProcedure(name);\n }\n\n const queryIdentity =\n proc.procedureType === \"query\"\n ? (proc as { queryIdentity?: RegisteredProcedure<TContext>[\"queryIdentity\"] }).queryIdentity\n : undefined;\n\n this.procedureRegistry.set(name, {\n name,\n type: proc.procedureType,\n internal: proc.internal,\n inputSchema: proc.inputSchema,\n fn: proc.fn,\n queryIdentity,\n });\n }\n\n /** Get a registered procedure by name (runtime lookup) */\n getProcedure<TContext = unknown>(name: string): RegisteredProcedure<TContext> | undefined {\n return this.procedureRegistry.get(name);\n }\n\n /** Get all registered procedure names */\n getProcedureNames(): string[] {\n return [...this.procedureRegistry.keys()];\n }\n\n /** Get all registered procedures */\n getAllProcedures(): Map<string, RegisteredProcedure> {\n return new Map(this.procedureRegistry);\n }\n\n /** Clear the registry (for testing only) */\n clearRegistry(): void {\n this.procedureRegistry.clear();\n this.clearInternalProcedures();\n }\n\n markInternalProcedure(name: string): void {\n this.internalProcedureNames.add(name);\n }\n\n isInternalProcedure(name: string): boolean {\n return this.internalProcedureNames.has(name);\n }\n\n clearInternalProcedures(): void {\n this.internalProcedureNames.clear();\n }\n}"],"mappings":";;;;;;;;;;;;;;;;AAsEA,SAAgB,OACd,QAC+B;CAC/B,MAAM,WAAW,mBAAmB,OAAO,eAAe,SAAS;CAGnE,KAAK,MAAM,CAAC,MAAM,SAAS,OAAO,QAAQ,OAAO,UAAU,GACzD,SAAS,kBAAkB,MAAM,IAAI;CAIvC,OAAO;EACL,OAAO;EACP,YAAY,OAAO;EACnB,aAAa,OAAO,eAAe;CACrC;AACF;AAaA,MAAM,kCAAkB,IAAI,IAA6B;AAEzD,SAAgB,mBAAmB,WAAoC;CACrE,IAAI,WAAW,gBAAgB,IAAI,SAAS;CAC5C,IAAI,CAAC,UAAU;EACb,WAAW,IAAI,gBAAgB;EAC/B,gBAAgB,IAAI,WAAW,QAAQ;CACzC;CACA,OAAO;AACT;AAEA,IAAa,kBAAb,MAA6B;CAC3B,oCAAoB,IAAI,IAAsC;CAC9D,yCAAyB,IAAI,IAAY;CAEzC,kBAA4B,MAAc,MAAoC;EAC5E,IAAI,KAAK,kBAAkB,IAAI,IAAI,GACjC,MAAM,IAAI,MACR,uBAAuB,KAAK,oFAE9B;EAIF,IAAI,KAAK,UACP,KAAK,sBAAsB,IAAI;EAGjC,MAAM,gBACJ,KAAK,kBAAkB,UAClB,KAA4E,gBAC7E,KAAA;EAEN,KAAK,kBAAkB,IAAI,MAAM;GAC/B;GACA,MAAM,KAAK;GACX,UAAU,KAAK;GACf,aAAa,KAAK;GAClB,IAAI,KAAK;GACT;EACF,CAAC;CACH;;CAGA,aAAiC,MAAyD;EACxF,OAAO,KAAK,kBAAkB,IAAI,IAAI;CACxC;;CAGA,oBAA8B;EAC5B,OAAO,CAAC,GAAG,KAAK,kBAAkB,KAAK,CAAC;CAC1C;;CAGA,mBAAqD;EACnD,OAAO,IAAI,IAAI,KAAK,iBAAiB;CACvC;;CAGA,gBAAsB;EACpB,KAAK,kBAAkB,MAAM;EAC7B,KAAK,wBAAwB;CAC/B;CAEA,sBAAsB,MAAoB;EACxC,KAAK,uBAAuB,IAAI,IAAI;CACtC;CAEA,oBAAoB,MAAuB;EACzC,OAAO,KAAK,uBAAuB,IAAI,IAAI;CAC7C;CAEA,0BAAgC;EAC9B,KAAK,uBAAuB,MAAM;CACpC;AACF"}
@@ -1,2 +1,2 @@
1
- import { $ as PublicProcedures, $n as CompareOperator, Ar as RetryConfig, At as ResultOf, Cr as RawPointReadSchema, Ct as createQueryBuilder, Dn as RawClient, Dr as RawReadEntrySchema, Dt as DefsToMap, Er as RawReadEntry, Et as AnyQueryDef, Fr as bytesFromJson, Ft as TxContext, G as RPCError, Gt as matchesPredicate, Ir as normalizeIdToBytes, J as ActionProcedures, Jn as BigIntSchema, K as WSClientOptions, Kn as AndPredicate, Lr as normalizeToBytes, Mr as WriteEntrySchema, Mt as defineQuery, Nr as WriteOp, Nt as DbReader, Or as ReadEntry, Ot as ParamsOf, Pr as WriteOpSchema, Pt as DbWriter, Q as ProcedureNames, Qn as CommitTs, Sn as DbQueryResult, Sr as RawPointRead, St as createMutationBuilder, Tn as PooledClient, Tr as RawRangeReadSchema, Tt as sleep, U as ClientPublicState, W as HeartbeatOptions, Xn as CachedPgMetadataSchema, Y as AppRouter, Yn as CachedPgMetadata, Z as MutationProcedures, Zn as CommitLogEntry, Zt as ComputedFieldConfig, _r as QueryCacheMetadata, _t as QueryCtx, a as CallOptions, ar as MutationResult, at as ActionConfig, br as RangeRead, bt as TypeOf, c as LiveQueryHandle, cr as OccConflictError, ct as ActionProcedure, d as WSClientMethods, dr as PointRead, dt as MutationConfig, er as CompareOperatorSchema, et as QueryProcedures, f as createClient, fn as SchemaColumnsOptions, fr as PointReadSchema, ft as MutationCtx, gn as defineSchema, gr as QueryCacheEntrySchema, gt as QueryConfig, hn as defineComputedField, hr as QueryCacheEntry, ht as OutputOf, i as createCaller, ir as LiveResult, it as router, jr as WriteEntry, jt as _resetGlobalDefs, kr as ReadEntrySchema, kt as QueryDefinition, l as LiveQueryState, lr as OrPredicate, lt as AnyProcedure, mr as PredicateSchema, mt as MutationProcedure, n as CallerFromRouter, nn as InsertData, nr as LeafPredicate, nt as Router, o as ClientFromProcedures, or as NO_RETRY, ot as ActionCtx, pn as SchemaDefinition, pr as Predicate, pt as MutationFn, q as WsClientManager, qn as AndPredicateSchema, qt as ColumnCodec, r as CallerOptions, rn as Model, rr as LeafPredicateSchema, s as ClientOptions, sr as OccAbortError, st as ActionFn, t as CallerFromProcedures, tn as InferSchema, tr as DEFAULT_RETRY, tt as RegisteredProcedure, u as LiveQueryStatus, un as SchemaCodecs, ur as OrPredicateSchema, ut as ContextOf, vr as QueryCacheMetadataSchema, vt as QueryFn, wr as RawRangeRead, wt as SupaliveDb, xn as Database, xr as RangeReadSchema, xt as createActionBuilder, yr as QuerySpec, yt as QueryProcedure } from "../../index-CaWMDqq0.js";
1
+ import { $ as PublicProcedures, $n as CompareOperator, Ar as RetryConfig, At as ResultOf, Cr as RawPointReadSchema, Ct as createQueryBuilder, Dn as RawClient, Dr as RawReadEntrySchema, Dt as DefsToMap, Er as RawReadEntry, Et as AnyQueryDef, Fr as bytesFromJson, Ft as TxContext, G as RPCError, Gt as matchesPredicate, Ir as normalizeIdToBytes, J as ActionProcedures, Jn as BigIntSchema, K as WSClientOptions, Kn as AndPredicate, Lr as normalizeToBytes, Mr as WriteEntrySchema, Mt as defineQuery, Nr as WriteOp, Nt as DbReader, Or as ReadEntry, Ot as ParamsOf, Pr as WriteOpSchema, Pt as DbWriter, Q as ProcedureNames, Qn as CommitTs, Sn as DbQueryResult, Sr as RawPointRead, St as createMutationBuilder, Tn as PooledClient, Tr as RawRangeReadSchema, Tt as sleep, U as ClientPublicState, W as HeartbeatOptions, Xn as CachedPgMetadataSchema, Y as AppRouter, Yn as CachedPgMetadata, Z as MutationProcedures, Zn as CommitLogEntry, Zt as ComputedFieldConfig, _r as QueryCacheMetadata, _t as QueryCtx, a as CallOptions, ar as MutationResult, at as ActionConfig, br as RangeRead, bt as TypeOf, c as LiveQueryHandle, cr as OccConflictError, ct as ActionProcedure, d as WSClientMethods, dr as PointRead, dt as MutationConfig, er as CompareOperatorSchema, et as QueryProcedures, f as createClient, fn as SchemaColumnsOptions, fr as PointReadSchema, ft as MutationCtx, gn as defineSchema, gr as QueryCacheEntrySchema, gt as QueryConfig, hn as defineComputedField, hr as QueryCacheEntry, ht as OutputOf, i as createCaller, ir as LiveResult, it as router, jr as WriteEntry, jt as _resetGlobalDefs, kr as ReadEntrySchema, kt as QueryDefinition, l as LiveQueryState, lr as OrPredicate, lt as AnyProcedure, mr as PredicateSchema, mt as MutationProcedure, n as CallerFromRouter, nn as InsertData, nr as LeafPredicate, nt as Router, o as ClientFromProcedures, or as NO_RETRY, ot as ActionCtx, pn as SchemaDefinition, pr as Predicate, pt as MutationFn, q as WsClientManager, qn as AndPredicateSchema, qt as ColumnCodec, r as CallerOptions, rn as Model, rr as LeafPredicateSchema, s as ClientOptions, sr as OccAbortError, st as ActionFn, t as CallerFromProcedures, tn as InferSchema, tr as DEFAULT_RETRY, tt as RegisteredProcedure, u as LiveQueryStatus, un as SchemaCodecs, ur as OrPredicateSchema, ut as ContextOf, vr as QueryCacheMetadataSchema, vt as QueryFn, wr as RawRangeRead, wt as SupaliveDb, xn as Database, xr as RangeReadSchema, xt as createActionBuilder, yr as QuerySpec, yt as QueryProcedure } from "../../index-DouKwYL6.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 };
@@ -0,0 +1,38 @@
1
+ import { nt as Router } from "../../index-CaWMDqq0.js";
2
+ import { z as z$1 } from "zod";
3
+
4
+ //#region src/db/codegen/zod-to-json.d.ts
5
+ interface JsonSchemaType {
6
+ type?: "string" | "number" | "boolean" | "integer" | "array" | "object";
7
+ format?: string;
8
+ enum?: (string | number)[];
9
+ items?: JsonSchemaType;
10
+ properties?: Record<string, JsonSchemaType>;
11
+ required?: string[];
12
+ additionalProperties?: JsonSchemaType;
13
+ nullable?: boolean;
14
+ anyOf?: JsonSchemaType[];
15
+ allOf?: JsonSchemaType[];
16
+ $ref?: string;
17
+ const?: string | number | boolean;
18
+ description?: string;
19
+ }
20
+ declare function zodToJsonSchema(schema: z$1.ZodType<any>): JsonSchemaType;
21
+ //#endregion
22
+ //#region src/db/codegen/manifest.d.ts
23
+ interface ProcedureManifest {
24
+ name: string;
25
+ type: "query" | "mutation" | "action";
26
+ group: string;
27
+ input: JsonSchemaType | null;
28
+ output: null;
29
+ }
30
+ interface RouterManifest {
31
+ version: "1";
32
+ procedures: ProcedureManifest[];
33
+ definitions: Record<string, JsonSchemaType>;
34
+ }
35
+ declare function extractRouterManifest(router: Router): RouterManifest;
36
+ //#endregion
37
+ export { type JsonSchemaType, type ProcedureManifest, type RouterManifest, extractRouterManifest, zodToJsonSchema };
38
+ //# sourceMappingURL=codegen.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codegen.d.ts","names":[],"sources":["../../../src/db/codegen/zod-to-json.ts","../../../src/db/codegen/manifest.ts"],"mappings":";;;;UAEiB,cAAA;EACb,IAAA;EACA,MAAA;EACA,IAAA;EACA,KAAA,GAAQ,cAAA;EACR,UAAA,GAAa,MAAA,SAAe,cAAA;EAC5B,QAAA;EACA,oBAAA,GAAuB,cAAA;EACvB,QAAA;EACA,KAAA,GAAQ,cAAA;EACR,KAAA,GAAQ,cAAA;EACR,IAAA;EACA,KAAA;EACA,WAAA;AAAA;AAAA,iBAWY,eAAA,CAAgB,MAAA,EAAQ,GAAA,CAAE,OAAA,QAAe,cAAc;;;UCtBtD,iBAAA;EACb,IAAA;EACA,IAAA;EACA,KAAA;EACA,KAAA,EAAO,cAAc;EACrB,MAAA;AAAA;AAAA,UAGa,cAAA;EACb,OAAA;EACA,UAAA,EAAY,iBAAA;EACZ,WAAA,EAAa,MAAA,SAAe,cAAA;AAAA;AAAA,iBAYhB,qBAAA,CAAsB,MAAA,EAAQ,MAAA,GAAS,cAAc"}
@@ -0,0 +1,134 @@
1
+ import { z as z$1 } from "zod";
2
+ //#region src/db/codegen/zod-to-json.ts
3
+ function isOptionalField(schema) {
4
+ return schema instanceof z$1.ZodOptional || schema instanceof z$1.ZodNullable || schema instanceof z$1.ZodDefault;
5
+ }
6
+ function zodToJsonSchema(schema) {
7
+ if (schema instanceof z$1.ZodString) return { type: "string" };
8
+ if (schema instanceof z$1.ZodNumber) return { type: "number" };
9
+ if (schema instanceof z$1.ZodBoolean) return { type: "boolean" };
10
+ if (schema instanceof z$1.ZodBigInt) return {
11
+ type: "string",
12
+ format: "bigint"
13
+ };
14
+ if (schema instanceof z$1.ZodDate) return {
15
+ type: "string",
16
+ format: "date-time"
17
+ };
18
+ if (schema instanceof z$1.ZodEnum) {
19
+ const entries = schema._def?.entries;
20
+ if (entries && typeof entries === "object") {
21
+ const values = Object.values(entries).filter((v) => typeof v === "string");
22
+ if (values.length > 0) return {
23
+ type: "string",
24
+ enum: values
25
+ };
26
+ }
27
+ return { type: "string" };
28
+ }
29
+ if (schema instanceof z$1.ZodArray) {
30
+ const inner = schema._def?.type;
31
+ return {
32
+ type: "array",
33
+ items: inner ? zodToJsonSchema(inner) : { type: "string" }
34
+ };
35
+ }
36
+ if (schema instanceof z$1.ZodObject) {
37
+ const shape = schema._def?.shape ?? schema.shape;
38
+ const properties = {};
39
+ const required = [];
40
+ if (shape && typeof shape === "object") for (const [key, field] of Object.entries(shape)) {
41
+ if (!field) continue;
42
+ properties[key] = zodToJsonSchema(field);
43
+ if (!isOptionalField(field)) required.push(key);
44
+ }
45
+ return {
46
+ type: "object",
47
+ properties,
48
+ required: required.length > 0 ? required : void 0
49
+ };
50
+ }
51
+ if (schema instanceof z$1.ZodRecord) {
52
+ const valueType = schema._def?.valueType;
53
+ return {
54
+ type: "object",
55
+ additionalProperties: valueType ? zodToJsonSchema(valueType) : { type: "string" }
56
+ };
57
+ }
58
+ if (schema instanceof z$1.ZodOptional) {
59
+ const inner = schema._def?.innerType;
60
+ return {
61
+ ...inner ? zodToJsonSchema(inner) : { type: "string" },
62
+ nullable: true
63
+ };
64
+ }
65
+ if (schema instanceof z$1.ZodNullable) {
66
+ const inner = schema._def?.innerType;
67
+ return {
68
+ ...inner ? zodToJsonSchema(inner) : { type: "string" },
69
+ nullable: true
70
+ };
71
+ }
72
+ if (schema instanceof z$1.ZodDefault) {
73
+ const inner = schema._def?.innerType;
74
+ return inner ? zodToJsonSchema(inner) : { type: "string" };
75
+ }
76
+ if (schema instanceof z$1.ZodUnion) {
77
+ const options = schema._def?.options;
78
+ if (Array.isArray(options) && options.length > 0) return { anyOf: options.map((o) => zodToJsonSchema(o)) };
79
+ return { type: "string" };
80
+ }
81
+ if (schema instanceof z$1.ZodIntersection) {
82
+ const left = schema._def?.left;
83
+ const right = schema._def?.right;
84
+ if (left && right) return { allOf: [zodToJsonSchema(left), zodToJsonSchema(right)] };
85
+ return { type: "object" };
86
+ }
87
+ if (schema instanceof z$1.ZodLiteral) return { const: schema._def?.value };
88
+ if (schema instanceof z$1.ZodPipe || schema instanceof z$1.ZodTransform) {
89
+ const inner = schema._def?.schema ?? schema._def?.input;
90
+ return inner ? zodToJsonSchema(inner) : { type: "string" };
91
+ }
92
+ if (schema instanceof z$1.ZodAny || schema instanceof z$1.ZodUnknown) return {};
93
+ return { type: "string" };
94
+ }
95
+ //#endregion
96
+ //#region src/db/codegen/manifest.ts
97
+ function extractGroup(name) {
98
+ const dot = name.indexOf(".");
99
+ return dot > 0 ? name.slice(0, dot) : name;
100
+ }
101
+ function isPublicProcedure(proc) {
102
+ return !proc.internal;
103
+ }
104
+ function extractRouterManifest(router) {
105
+ const procedures = [];
106
+ const definitions = {};
107
+ for (const [name, proc] of Object.entries(router.procedures)) {
108
+ if (!isPublicProcedure(proc)) continue;
109
+ let input = null;
110
+ try {
111
+ const inputSchema = proc.inputSchema;
112
+ if (inputSchema) input = zodToJsonSchema(inputSchema);
113
+ } catch {
114
+ input = null;
115
+ }
116
+ procedures.push({
117
+ name,
118
+ type: proc.procedureType,
119
+ group: extractGroup(name),
120
+ input,
121
+ output: null
122
+ });
123
+ }
124
+ procedures.sort((a, b) => a.name.localeCompare(b.name));
125
+ return {
126
+ version: "1",
127
+ procedures,
128
+ definitions
129
+ };
130
+ }
131
+ //#endregion
132
+ export { extractRouterManifest, zodToJsonSchema };
133
+
134
+ //# sourceMappingURL=codegen.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codegen.js","names":["z"],"sources":["../../../src/db/codegen/zod-to-json.ts","../../../src/db/codegen/manifest.ts"],"sourcesContent":["import { z } from \"zod\";\n\nexport interface JsonSchemaType {\n type?: \"string\" | \"number\" | \"boolean\" | \"integer\" | \"array\" | \"object\";\n format?: string;\n enum?: (string | number)[];\n items?: JsonSchemaType;\n properties?: Record<string, JsonSchemaType>;\n required?: string[];\n additionalProperties?: JsonSchemaType;\n nullable?: boolean;\n anyOf?: JsonSchemaType[];\n allOf?: JsonSchemaType[];\n $ref?: string;\n const?: string | number | boolean;\n description?: string;\n}\n\nfunction isOptionalField(schema: z.ZodType<any>): boolean {\n return (\n schema instanceof z.ZodOptional ||\n schema instanceof z.ZodNullable ||\n schema instanceof z.ZodDefault\n );\n}\n\nexport function zodToJsonSchema(schema: z.ZodType<any>): JsonSchemaType {\n if (schema instanceof z.ZodString) {\n return { type: \"string\" };\n }\n if (schema instanceof z.ZodNumber) {\n return { type: \"number\" };\n }\n if (schema instanceof z.ZodBoolean) {\n return { type: \"boolean\" };\n }\n if (schema instanceof z.ZodBigInt) {\n return { type: \"string\", format: \"bigint\" };\n }\n if (schema instanceof z.ZodDate) {\n return { type: \"string\", format: \"date-time\" };\n }\n if (schema instanceof z.ZodEnum) {\n const entries = (schema as any)._def?.entries;\n if (entries && typeof entries === \"object\") {\n const values = Object.values(entries).filter(v => typeof v === \"string\") as string[];\n if (values.length > 0) {\n return { type: \"string\", enum: values };\n }\n }\n return { type: \"string\" };\n }\n if (schema instanceof z.ZodArray) {\n const inner = (schema as any)._def?.type;\n return {\n type: \"array\",\n items: inner ? zodToJsonSchema(inner) : { type: \"string\" },\n };\n }\n if (schema instanceof z.ZodObject) {\n const shape = (schema as any)._def?.shape ?? (schema as any).shape;\n const properties: Record<string, JsonSchemaType> = {};\n const required: string[] = [];\n if (shape && typeof shape === \"object\") {\n for (const [key, field] of Object.entries(shape)) {\n if (!field) continue;\n const fieldSchema = zodToJsonSchema(field as z.ZodType<any>);\n properties[key] = fieldSchema;\n if (!isOptionalField(field as z.ZodType<any>)) {\n required.push(key);\n }\n }\n }\n return { type: \"object\", properties, required: required.length > 0 ? required : undefined };\n }\n if (schema instanceof z.ZodRecord) {\n const valueType = (schema as any)._def?.valueType;\n return {\n type: \"object\",\n additionalProperties: valueType ? zodToJsonSchema(valueType) : { type: \"string\" },\n };\n }\n if (schema instanceof z.ZodOptional) {\n const inner = (schema as any)._def?.innerType;\n const innerSchema = inner ? zodToJsonSchema(inner) : { type: \"string\" };\n return { ...innerSchema, nullable: true };\n }\n if (schema instanceof z.ZodNullable) {\n const inner = (schema as any)._def?.innerType;\n const innerSchema = inner ? zodToJsonSchema(inner) : { type: \"string\" };\n return { ...innerSchema, nullable: true };\n }\n if (schema instanceof z.ZodDefault) {\n const inner = (schema as any)._def?.innerType;\n return inner ? zodToJsonSchema(inner) : { type: \"string\" };\n }\n if (schema instanceof z.ZodUnion) {\n const options = (schema as any)._def?.options;\n if (Array.isArray(options) && options.length > 0) {\n return { anyOf: options.map(o => zodToJsonSchema(o)) };\n }\n return { type: \"string\" };\n }\n if (schema instanceof z.ZodIntersection) {\n const left = (schema as any)._def?.left;\n const right = (schema as any)._def?.right;\n if (left && right) {\n return { allOf: [zodToJsonSchema(left), zodToJsonSchema(right)] };\n }\n return { type: \"object\" };\n }\n if (schema instanceof z.ZodLiteral) {\n return { const: (schema as any)._def?.value };\n }\n if (schema instanceof z.ZodPipe || schema instanceof z.ZodTransform) {\n const inner = (schema as any)._def?.schema ?? (schema as any)._def?.input;\n return inner ? zodToJsonSchema(inner) : { type: \"string\" };\n }\n if (schema instanceof z.ZodAny || schema instanceof z.ZodUnknown) {\n return {};\n }\n return { type: \"string\" };\n}\n","import type { Router } from \"../../router/router\";\nimport type { AnyProcedure } from \"../../router/procedure\";\nimport { zodToJsonSchema, type JsonSchemaType } from \"./zod-to-json\";\n\nexport interface ProcedureManifest {\n name: string;\n type: \"query\" | \"mutation\" | \"action\";\n group: string;\n input: JsonSchemaType | null;\n output: null; // output type inference requires runtime annotation\n}\n\nexport interface RouterManifest {\n version: \"1\";\n procedures: ProcedureManifest[];\n definitions: Record<string, JsonSchemaType>;\n}\n\nfunction extractGroup(name: string): string {\n const dot = name.indexOf(\".\");\n return dot > 0 ? name.slice(0, dot) : name;\n}\n\nfunction isPublicProcedure(proc: AnyProcedure): boolean {\n return !proc.internal;\n}\n\nexport function extractRouterManifest(router: Router): RouterManifest {\n const procedures: ProcedureManifest[] = [];\n const definitions: Record<string, JsonSchemaType> = {};\n\n for (const [name, proc] of Object.entries(router.procedures)) {\n if (!isPublicProcedure(proc)) continue;\n\n let input: JsonSchemaType | null = null;\n try {\n const inputSchema = proc.inputSchema;\n if (inputSchema) {\n input = zodToJsonSchema(inputSchema as any);\n }\n } catch {\n input = null;\n }\n\n procedures.push({\n name,\n type: proc.procedureType as \"query\" | \"mutation\" | \"action\",\n group: extractGroup(name),\n input,\n output: null,\n });\n }\n\n procedures.sort((a, b) => a.name.localeCompare(b.name));\n\n return {\n version: \"1\",\n procedures,\n definitions,\n };\n}\n"],"mappings":";;AAkBA,SAAS,gBAAgB,QAAiC;CACtD,OACI,kBAAkBA,IAAE,eACpB,kBAAkBA,IAAE,eACpB,kBAAkBA,IAAE;AAE5B;AAEA,SAAgB,gBAAgB,QAAwC;CACpE,IAAI,kBAAkBA,I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AC7D;CACA,IAAI,kBAAkBA,IAAE,UAAU,kBAAkBA,IAAE,YAClD,OAAO,CAAC;CAEZ,OAAO,EAAE,MAAM,SAAS;AAC5B;;;ACxGA,SAAS,aAAa,MAAsB;CACxC,MAAM,MAAM,KAAK,QAAQ,GAAG;CAC5B,OAAO,MAAM,IAAI,KAAK,MAAM,GAAG,GAAG,IAAI;AAC1C;AAEA,SAAS,kBAAkB,MAA6B;CACpD,OAAO,CAAC,KAAK;AACjB;AAEA,SAAgB,sBAAsB,QAAgC;CAClE,MAAM,aAAkC,CAAC;CACzC,MAAM,cAA8C,CAAC;CAErD,KAAK,MAAM,CAAC,MAAM,SAAS,OAAO,QAAQ,OAAO,UAAU,GAAG;EAC1D,IAAI,CAAC,kBAAkB,IAAI,GAAG;EAE9B,IAAI,QAA+B;EACnC,IAAI;GACA,MAAM,cAAc,KAAK;GACzB,IAAI,aACA,QAAQ,gBAAgB,WAAkB;EAElD,QAAQ;GACJ,QAAQ;EACZ;EAEA,WAAW,KAAK;GACZ;GACA,MAAM,KAAK;GACX,OAAO,aAAa,IAAI;GACxB;GACA,QAAQ;EACZ,CAAC;CACL;CAEA,WAAW,MAAM,GAAG,MAAM,EAAE,KAAK,cAAc,EAAE,IAAI,CAAC;CAEtD,OAAO;EACH,SAAS;EACT;EACA;CACJ;AACJ"}
@@ -1,2 +1,2 @@
1
- import { t as MySqlDatabase } from "../../mysql-Cxd4Uq5p.js";
1
+ import { t as MySqlDatabase } from "../../mysql-Bxurg_PH.js";
2
2
  export { MySqlDatabase };
@@ -1,2 +1,2 @@
1
- import { t as PgDatabase } from "../../postgres-Ck-xt72U.js";
1
+ import { t as PgDatabase } from "../../postgres-CfT_aDx3.js";
2
2
  export { PgDatabase };