@noormdev/sdk 1.0.0-alpha.24 → 1.0.0-alpha.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1971,6 +1971,38 @@ export interface ImportOptions {
1971
1971
  /** Truncate target table before import. Default: false. */
1972
1972
  truncate?: boolean;
1973
1973
  }
1974
+ /**
1975
+ * Extract the args type from a proc/func/tvf entry.
1976
+ *
1977
+ * Supports tuple form `[Args, Return]` and plain `void`.
1978
+ * Non-tuple entries pass through as-is for backward compat.
1979
+ *
1980
+ * @example
1981
+ * ```typescript
1982
+ * ExtractArgs<[{ id: number }, User]> // { id: number }
1983
+ * ExtractArgs<void> // void
1984
+ * ```
1985
+ */
1986
+ export type ExtractArgs<E> = E extends [
1987
+ infer A,
1988
+ unknown
1989
+ ] ? A : E;
1990
+ /**
1991
+ * Extract the return type from a proc/func/tvf entry.
1992
+ *
1993
+ * Returns the second element of a `[Args, Return]` tuple.
1994
+ * Falls back to `unknown` for `void` or non-tuple entries.
1995
+ *
1996
+ * @example
1997
+ * ```typescript
1998
+ * ExtractReturn<[{ id: number }, User]> // User
1999
+ * ExtractReturn<void> // unknown
2000
+ * ```
2001
+ */
2002
+ export type ExtractReturn<E> = E extends [
2003
+ unknown,
2004
+ infer R
2005
+ ] ? R : unknown;
1974
2006
  export interface ContextState {
1975
2007
  connection: ConnectionResult | null;
1976
2008
  config: Config;
@@ -3698,19 +3730,19 @@ export declare class NoormOps {
3698
3730
  */
3699
3731
  export interface ImpersonatedScope<DB = unknown, Procs = object, Funcs = object, Tvfs = object> {
3700
3732
  kysely: Kysely<DB>;
3701
- proc: <T = unknown, N extends keyof Procs & string = keyof Procs & string>(name: N, ...args: Procs[N] extends void ? [
3733
+ proc: <N extends keyof Procs & string = keyof Procs & string, T = ExtractReturn<Procs[N]>>(name: N, ...args: ExtractArgs<Procs[N]> extends void ? [
3702
3734
  ] : [
3703
- params: Procs[N]
3735
+ params: ExtractArgs<Procs[N]>
3704
3736
  ]) => Promise<T[]>;
3705
- func: <T = unknown, N extends keyof Funcs & string = keyof Funcs & string>(name: N, ...args: Funcs[N] extends void ? [
3737
+ func: <N extends keyof Funcs & string = keyof Funcs & string, T = ExtractReturn<Funcs[N]>>(name: N, ...args: ExtractArgs<Funcs[N]> extends void ? [
3706
3738
  column: string
3707
3739
  ] : [
3708
- params: Funcs[N],
3740
+ params: ExtractArgs<Funcs[N]>,
3709
3741
  column: string
3710
3742
  ]) => Promise<T>;
3711
- tvf: <T = unknown, N extends keyof Tvfs & string = keyof Tvfs & string>(name: N, ...args: Tvfs[N] extends void ? [
3743
+ tvf: <N extends keyof Tvfs & string = keyof Tvfs & string, T = ExtractReturn<Tvfs[N]>>(name: N, ...args: ExtractArgs<Tvfs[N]> extends void ? [
3712
3744
  ] : [
3713
- params: Tvfs[N]
3745
+ params: ExtractArgs<Tvfs[N]>
3714
3746
  ]) => Promise<T[]>;
3715
3747
  transaction: <T>(fn: (trx: Transaction<DB>) => Promise<T>) => Promise<T>;
3716
3748
  revert: () => Promise<void>;
@@ -3801,8 +3833,11 @@ export declare class Context<DB = unknown, Procs = object, Funcs = object, Tvfs
3801
3833
  *
3802
3834
  * @example
3803
3835
  * ```typescript
3804
- * // Named params
3805
- * const users = await ctx.proc<User>('get_users', { department_id: 1 });
3836
+ * // Return type inferred from tuple definition
3837
+ * const users = await ctx.proc('get_users', { department_id: 1 });
3838
+ *
3839
+ * // Explicit return type override
3840
+ * const users = await ctx.proc<'get_users', SpecialUser>('get_users', { department_id: 1 });
3806
3841
  *
3807
3842
  * // Positional params
3808
3843
  * await ctx.proc('simple_proc', [42, 'hello']);
@@ -3811,9 +3846,9 @@ export declare class Context<DB = unknown, Procs = object, Funcs = object, Tvfs
3811
3846
  * await ctx.proc('refresh_cache');
3812
3847
  * ```
3813
3848
  */
3814
- proc<T = unknown, N extends keyof Procs & string = keyof Procs & string>(name: N, ...args: Procs[N] extends void ? [
3849
+ proc<N extends keyof Procs & string = keyof Procs & string, T = ExtractReturn<Procs[N]>>(name: N, ...args: ExtractArgs<Procs[N]> extends void ? [
3815
3850
  ] : [
3816
- params: Procs[N]
3851
+ params: ExtractArgs<Procs[N]>
3817
3852
  ]): Promise<T[]>;
3818
3853
  /**
3819
3854
  * Call a database function and return the scalar result.
@@ -3823,20 +3858,20 @@ export declare class Context<DB = unknown, Procs = object, Funcs = object, Tvfs
3823
3858
  *
3824
3859
  * @example
3825
3860
  * ```typescript
3826
- * // Named params + column alias
3827
- * const result = await ctx.func<{ total: number }>('calc_total', { order_id: 42 }, 'total');
3861
+ * // Return type inferred from tuple definition
3862
+ * const result = await ctx.func('calc_total', { order_id: 42 }, 'total');
3828
3863
  *
3829
- * // Positional params + column alias
3830
- * const sum = await ctx.func<{ result: number }>('add_numbers', [1, 2], 'result');
3864
+ * // Explicit return type override
3865
+ * const result = await ctx.func<'calc_total', { total: number }>('calc_total', { order_id: 42 }, 'total');
3831
3866
  *
3832
3867
  * // No params — just column alias
3833
- * const ver = await ctx.func<{ v: string }>('get_version', 'v');
3868
+ * const ver = await ctx.func('get_version', 'v');
3834
3869
  * ```
3835
3870
  */
3836
- func<T = unknown, N extends keyof Funcs & string = keyof Funcs & string>(name: N, ...args: Funcs[N] extends void ? [
3871
+ func<N extends keyof Funcs & string = keyof Funcs & string, T = ExtractReturn<Funcs[N]>>(name: N, ...args: ExtractArgs<Funcs[N]> extends void ? [
3837
3872
  column: string
3838
3873
  ] : [
3839
- params: Funcs[N],
3874
+ params: ExtractArgs<Funcs[N]>,
3840
3875
  column: string
3841
3876
  ]): Promise<T>;
3842
3877
  /**
@@ -3848,19 +3883,19 @@ export declare class Context<DB = unknown, Procs = object, Funcs = object, Tvfs
3848
3883
  *
3849
3884
  * @example
3850
3885
  * ```typescript
3851
- * // Named params
3852
- * const sessions = await ctx.tvf<Session>('validate_session', { session_key: key });
3886
+ * // Return type inferred from tuple definition
3887
+ * const sessions = await ctx.tvf('validate_session', { session_key: key });
3853
3888
  *
3854
- * // Positional params
3855
- * const results = await ctx.tvf<Result>('search_products', ['widget', 100]);
3889
+ * // Explicit return type override
3890
+ * const sessions = await ctx.tvf<'validate_session', SpecialSession>('validate_session', { session_key: key });
3856
3891
  *
3857
3892
  * // No params
3858
- * const items = await ctx.tvf<Item>('get_active_items');
3893
+ * const items = await ctx.tvf('get_active_items');
3859
3894
  * ```
3860
3895
  */
3861
- tvf<T = unknown, N extends keyof Tvfs & string = keyof Tvfs & string>(name: N, ...args: Tvfs[N] extends void ? [
3896
+ tvf<N extends keyof Tvfs & string = keyof Tvfs & string, T = ExtractReturn<Tvfs[N]>>(name: N, ...args: ExtractArgs<Tvfs[N]> extends void ? [
3862
3897
  ] : [
3863
- params: Tvfs[N]
3898
+ params: ExtractArgs<Tvfs[N]>
3864
3899
  ]): Promise<T[]>;
3865
3900
  /**
3866
3901
  * Execute queries as a specific database principal.
@@ -3885,6 +3920,50 @@ export declare class Context<DB = unknown, Procs = object, Funcs = object, Tvfs
3885
3920
  impersonate<T>(username: string, fn: (scope: ImpersonatedScope<DB, Procs, Funcs, Tvfs>) => Promise<T>): Promise<T>;
3886
3921
  impersonate(username: string): Promise<ImpersonatedScope<DB, Procs, Funcs, Tvfs>>;
3887
3922
  }
3923
+ /**
3924
+ * A TVP marker that wraps row data with the required table type name.
3925
+ *
3926
+ * Use the `tvp()` helper to create instances. Column names are
3927
+ * inferred from the object keys of the first row.
3928
+ *
3929
+ * @example
3930
+ * ```typescript
3931
+ * interface MyProcs {
3932
+ * 'Checkout_trx': [{ Party: number; PaymentMethod: number; Items: TvpValue }, void];
3933
+ * }
3934
+ * ```
3935
+ */
3936
+ export interface TvpValue {
3937
+ readonly __noorm_tvp: true;
3938
+ readonly typeName: string;
3939
+ readonly rows: ReadonlyArray<Record<string, unknown>>;
3940
+ }
3941
+ /**
3942
+ * Create a Table-Valued Parameter for MSSQL stored procedure calls.
3943
+ *
3944
+ * Wraps an array of row objects as a TVP with the specified SQL Server
3945
+ * table type name. Column names are inferred from the first row's keys.
3946
+ *
3947
+ * @param typeName - SQL Server table type (e.g., 'CheckoutItems' or 'dbo.CheckoutItems')
3948
+ * @param rows - Array of row objects with consistent keys
3949
+ *
3950
+ * @example
3951
+ * ```typescript
3952
+ * // Named params
3953
+ * await ctx.proc('Checkout_trx', {
3954
+ * Party: 1,
3955
+ * PaymentMethod: 2,
3956
+ * Items: tvp('CheckoutItems', [
3957
+ * { Type: 1, ReferenceNo: 100, Qty: 5 },
3958
+ * { Type: 2, ReferenceNo: 200, Qty: 3 },
3959
+ * ]),
3960
+ * });
3961
+ *
3962
+ * // Positional params
3963
+ * await ctx.proc('Checkout_trx', [1, 2, tvp('CheckoutItems', items)]);
3964
+ * ```
3965
+ */
3966
+ export declare function tvp(typeName: string, rows: Record<string, unknown>[]): TvpValue;
3888
3967
  /**
3889
3968
  * Error thrown when requireTest is enabled but config.isTest is false.
3890
3969
  *
package/dist/index.js CHANGED
@@ -16781,10 +16781,45 @@ async function waitForIdentityToLoad(db, dialect) {
16781
16781
  context: { identity }
16782
16782
  });
16783
16783
  }
16784
+
16785
+ // src/sdk/tvp.ts
16786
+ var MSSQL_PARAM_LIMIT = 2100;
16787
+ function tvp(typeName, rows) {
16788
+ if (!typeName) {
16789
+ throw new Error("TVP type name is required.");
16790
+ }
16791
+ if (!Array.isArray(rows)) {
16792
+ throw new Error("TVP rows must be an array.");
16793
+ }
16794
+ if (rows.length > 1) {
16795
+ const expectedKeys = Object.keys(rows[0]).sort().join(",");
16796
+ for (let i = 1; i < rows.length; i++) {
16797
+ const rowKeys = Object.keys(rows[i]).sort().join(",");
16798
+ if (rowKeys !== expectedKeys) {
16799
+ throw new Error(
16800
+ `TVP row ${i} has mismatched keys. Expected [${Object.keys(rows[0]).join(", ")}] but got [${Object.keys(rows[i]).join(", ")}].`
16801
+ );
16802
+ }
16803
+ }
16804
+ }
16805
+ return {
16806
+ __noorm_tvp: true,
16807
+ typeName,
16808
+ rows
16809
+ };
16810
+ }
16811
+ function isTvp(value) {
16812
+ return typeof value === "object" && value !== null && "__noorm_tvp" in value && value["__noorm_tvp"] === true;
16813
+ }
16814
+
16815
+ // src/sdk/sql.ts
16784
16816
  function buildProcCall(dialect, name, params) {
16785
16817
  if (dialect === "sqlite") {
16786
16818
  throw new Error("SQLite does not support stored procedures.");
16787
16819
  }
16820
+ if (params && hasTvpParam(params) && dialect !== "mssql") {
16821
+ throw new Error("Table-valued parameters (TVP) are only supported on MSSQL.");
16822
+ }
16788
16823
  const rawName = sql.raw(name);
16789
16824
  if (!params || Array.isArray(params) && params.length === 0 || !Array.isArray(params) && Object.keys(params).length === 0) {
16790
16825
  if (dialect === "mssql") {
@@ -16804,11 +16839,17 @@ function buildFuncCall(dialect, name, column, params) {
16804
16839
  if (dialect === "sqlite") {
16805
16840
  throw new Error("SQLite does not support database function calls.");
16806
16841
  }
16842
+ if (params && hasTvpParam(params) && dialect !== "mssql") {
16843
+ throw new Error("Table-valued parameters (TVP) are only supported on MSSQL.");
16844
+ }
16807
16845
  const rawName = sql.raw(name);
16808
16846
  const rawCol = sql.raw(column);
16809
16847
  if (!params || Array.isArray(params) && params.length === 0 || !Array.isArray(params) && Object.keys(params).length === 0) {
16810
16848
  return sql`SELECT ${rawName}() AS ${rawCol}`;
16811
16849
  }
16850
+ if (dialect === "mssql" && hasTvpParam(params)) {
16851
+ return buildMssqlFuncWithTvp(rawName, rawCol, params);
16852
+ }
16812
16853
  if (dialect === "postgres" && !Array.isArray(params)) {
16813
16854
  const parts = Object.entries(params).map(
16814
16855
  ([key, val]) => sql`${sql.raw(key)} => ${val}`
@@ -16835,10 +16876,16 @@ function buildTvfCall(dialect, name, params) {
16835
16876
  if (dialect === "mysql") {
16836
16877
  throw new Error("MySQL does not support table-valued functions.");
16837
16878
  }
16879
+ if (params && hasTvpParam(params) && dialect !== "mssql") {
16880
+ throw new Error("Table-valued parameters (TVP) are only supported on MSSQL.");
16881
+ }
16838
16882
  const rawName = sql.raw(name);
16839
16883
  if (!params || Array.isArray(params) && params.length === 0 || !Array.isArray(params) && Object.keys(params).length === 0) {
16840
16884
  return sql`SELECT * FROM ${rawName}()`;
16841
16885
  }
16886
+ if (dialect === "mssql" && hasTvpParam(params)) {
16887
+ return buildMssqlTvfWithTvp(rawName, params);
16888
+ }
16842
16889
  if (dialect === "postgres" && !Array.isArray(params)) {
16843
16890
  const parts = Object.entries(params).map(
16844
16891
  ([key, val]) => sql`${sql.raw(key)} => ${val}`
@@ -16850,6 +16897,9 @@ function buildTvfCall(dialect, name, params) {
16850
16897
  return sql`SELECT * FROM ${rawName}(${joined})`;
16851
16898
  }
16852
16899
  function buildMssqlProc(rawName, params) {
16900
+ if (hasTvpParam(params)) {
16901
+ return buildMssqlProcWithTvp(rawName, params);
16902
+ }
16853
16903
  if (Array.isArray(params)) {
16854
16904
  const joined = sql.join(params.map((v) => sql`${v}`));
16855
16905
  return sql`EXEC ${rawName} ${joined}`;
@@ -16874,6 +16924,137 @@ function buildMysqlProc(rawName, params) {
16874
16924
  const joined = sql.join(values.map((v) => sql`${v}`));
16875
16925
  return sql`CALL ${rawName}(${joined})`;
16876
16926
  }
16927
+ function hasTvpParam(params) {
16928
+ const values = Array.isArray(params) ? params : Object.values(params);
16929
+ return values.some(isTvp);
16930
+ }
16931
+ function validateTvpParamCount(params) {
16932
+ const values = Array.isArray(params) ? params : Object.values(params);
16933
+ let count = 0;
16934
+ for (const val of values) {
16935
+ if (isTvp(val)) {
16936
+ if (val.rows.length > 0) {
16937
+ count += val.rows.length * Object.keys(val.rows[0]).length;
16938
+ }
16939
+ } else {
16940
+ count += 1;
16941
+ }
16942
+ }
16943
+ if (count > MSSQL_PARAM_LIMIT) {
16944
+ throw new Error(
16945
+ "TVP parameter count (" + count + ") exceeds MSSQL limit of " + MSSQL_PARAM_LIMIT + ". Split your TVP rows into smaller batches and call the procedure multiple times."
16946
+ );
16947
+ }
16948
+ }
16949
+ function buildMssqlProcWithTvp(rawName, params) {
16950
+ validateTvpParamCount(params);
16951
+ const preamble = [];
16952
+ const execParts = [];
16953
+ if (Array.isArray(params)) {
16954
+ for (let i = 0; i < params.length; i++) {
16955
+ const val = params[i];
16956
+ if (isTvp(val)) {
16957
+ const varName = `@__tvp_${i}`;
16958
+ appendTvpStatements(preamble, varName, val);
16959
+ execParts.push(sql.raw(varName));
16960
+ } else {
16961
+ execParts.push(sql`${val}`);
16962
+ }
16963
+ }
16964
+ } else {
16965
+ for (const [key, val] of Object.entries(params)) {
16966
+ if (isTvp(val)) {
16967
+ const varName = `@__tvp_${key}`;
16968
+ appendTvpStatements(preamble, varName, val);
16969
+ execParts.push(sql`${sql.raw(`@${key}`)} = ${sql.raw(varName)}`);
16970
+ } else {
16971
+ execParts.push(sql`${sql.raw(`@${key}`)} = ${val}`);
16972
+ }
16973
+ }
16974
+ }
16975
+ const execStmt = sql`EXEC ${rawName} ${sql.join(execParts)}`;
16976
+ if (preamble.length === 0) {
16977
+ return execStmt;
16978
+ }
16979
+ return sql.join([...preamble, execStmt], sql.raw("; "));
16980
+ }
16981
+ function appendTvpStatements(statements, varName, tvpVal) {
16982
+ statements.push(sql.raw(`DECLARE ${varName} ${tvpVal.typeName}`));
16983
+ if (tvpVal.rows.length === 0) return;
16984
+ const cols = Object.keys(tvpVal.rows[0]);
16985
+ const colList = cols.map((c) => `[${c}]`).join(", ");
16986
+ const rowFragments = tvpVal.rows.map((row) => {
16987
+ const values = cols.map((c) => sql`${row[c]}`);
16988
+ return sql`(${sql.join(values)})`;
16989
+ });
16990
+ statements.push(
16991
+ sql`INSERT INTO ${sql.raw(varName)} (${sql.raw(colList)}) VALUES ${sql.join(rowFragments)}`
16992
+ );
16993
+ }
16994
+ function buildMssqlFuncWithTvp(rawName, rawCol, params) {
16995
+ validateTvpParamCount(params);
16996
+ const preamble = [];
16997
+ const execParts = [];
16998
+ if (Array.isArray(params)) {
16999
+ for (let i = 0; i < params.length; i++) {
17000
+ const val = params[i];
17001
+ if (isTvp(val)) {
17002
+ const varName = `@__tvp_${i}`;
17003
+ appendTvpStatements(preamble, varName, val);
17004
+ execParts.push(sql.raw(varName));
17005
+ } else {
17006
+ execParts.push(sql`${val}`);
17007
+ }
17008
+ }
17009
+ } else {
17010
+ for (const [key, val] of Object.entries(params)) {
17011
+ if (isTvp(val)) {
17012
+ const varName = `@__tvp_${key}`;
17013
+ appendTvpStatements(preamble, varName, val);
17014
+ execParts.push(sql`${sql.raw(`@${key}`)} = ${sql.raw(varName)}`);
17015
+ } else {
17016
+ execParts.push(sql`${sql.raw(`@${key}`)} = ${val}`);
17017
+ }
17018
+ }
17019
+ }
17020
+ const funcStmt = sql`DECLARE @__result sql_variant; EXEC @__result = ${rawName} ${sql.join(execParts)}; SELECT @__result AS ${rawCol}`;
17021
+ if (preamble.length === 0) {
17022
+ return funcStmt;
17023
+ }
17024
+ return sql.join([...preamble, funcStmt], sql.raw("; "));
17025
+ }
17026
+ function buildMssqlTvfWithTvp(rawName, params) {
17027
+ validateTvpParamCount(params);
17028
+ const preamble = [];
17029
+ const callParts = [];
17030
+ if (Array.isArray(params)) {
17031
+ for (let i = 0; i < params.length; i++) {
17032
+ const val = params[i];
17033
+ if (isTvp(val)) {
17034
+ const varName = `@__tvp_${i}`;
17035
+ appendTvpStatements(preamble, varName, val);
17036
+ callParts.push(sql.raw(varName));
17037
+ } else {
17038
+ callParts.push(sql`${val}`);
17039
+ }
17040
+ }
17041
+ } else {
17042
+ for (const [key, val] of Object.entries(params)) {
17043
+ if (isTvp(val)) {
17044
+ const varName = `@__tvp_${key}`;
17045
+ appendTvpStatements(preamble, varName, val);
17046
+ callParts.push(sql.raw(varName));
17047
+ } else {
17048
+ callParts.push(sql`${val}`);
17049
+ }
17050
+ }
17051
+ }
17052
+ const selectStmt = sql`SELECT * FROM ${rawName}(${sql.join(callParts)})`;
17053
+ if (preamble.length === 0) {
17054
+ return selectStmt;
17055
+ }
17056
+ return sql.join([...preamble, selectStmt], sql.raw("; "));
17057
+ }
16877
17058
  var ChangeValidationError = class extends Error {
16878
17059
  constructor(changeName, issue2) {
16879
17060
  super(`Invalid change '${changeName}': ${issue2}`);
@@ -23352,7 +23533,12 @@ async function teardownSchema(db, dialect, options = {}) {
23352
23533
  }
23353
23534
  }
23354
23535
  if (!options.keepTypes) {
23355
- for (const type of types) {
23536
+ const sortedTypes = [...types].sort((a, b) => {
23537
+ if (a.kind === "composite" && b.kind !== "composite") return -1;
23538
+ if (a.kind !== "composite" && b.kind === "composite") return 1;
23539
+ return 0;
23540
+ });
23541
+ for (const type of sortedTypes) {
23356
23542
  dropped.types.push(type.name);
23357
23543
  statements.push(ops.dropType(type.name, type.schema));
23358
23544
  }
@@ -27364,8 +27550,11 @@ var Context = class {
27364
27550
  *
27365
27551
  * @example
27366
27552
  * ```typescript
27367
- * // Named params
27368
- * const users = await ctx.proc<User>('get_users', { department_id: 1 });
27553
+ * // Return type inferred from tuple definition
27554
+ * const users = await ctx.proc('get_users', { department_id: 1 });
27555
+ *
27556
+ * // Explicit return type override
27557
+ * const users = await ctx.proc<'get_users', SpecialUser>('get_users', { department_id: 1 });
27369
27558
  *
27370
27559
  * // Positional params
27371
27560
  * await ctx.proc('simple_proc', [42, 'hello']);
@@ -27391,14 +27580,14 @@ var Context = class {
27391
27580
  *
27392
27581
  * @example
27393
27582
  * ```typescript
27394
- * // Named params + column alias
27395
- * const result = await ctx.func<{ total: number }>('calc_total', { order_id: 42 }, 'total');
27583
+ * // Return type inferred from tuple definition
27584
+ * const result = await ctx.func('calc_total', { order_id: 42 }, 'total');
27396
27585
  *
27397
- * // Positional params + column alias
27398
- * const sum = await ctx.func<{ result: number }>('add_numbers', [1, 2], 'result');
27586
+ * // Explicit return type override
27587
+ * const result = await ctx.func<'calc_total', { total: number }>('calc_total', { order_id: 42 }, 'total');
27399
27588
  *
27400
27589
  * // No params — just column alias
27401
- * const ver = await ctx.func<{ v: string }>('get_version', 'v');
27590
+ * const ver = await ctx.func('get_version', 'v');
27402
27591
  * ```
27403
27592
  */
27404
27593
  async func(name, ...args) {
@@ -27424,14 +27613,14 @@ var Context = class {
27424
27613
  *
27425
27614
  * @example
27426
27615
  * ```typescript
27427
- * // Named params
27428
- * const sessions = await ctx.tvf<Session>('validate_session', { session_key: key });
27616
+ * // Return type inferred from tuple definition
27617
+ * const sessions = await ctx.tvf('validate_session', { session_key: key });
27429
27618
  *
27430
- * // Positional params
27431
- * const results = await ctx.tvf<Result>('search_products', ['widget', 100]);
27619
+ * // Explicit return type override
27620
+ * const sessions = await ctx.tvf<'validate_session', SpecialSession>('validate_session', { session_key: key });
27432
27621
  *
27433
27622
  * // No params
27434
- * const items = await ctx.tvf<Item>('get_active_items');
27623
+ * const items = await ctx.tvf('get_active_items');
27435
27624
  * ```
27436
27625
  */
27437
27626
  async tvf(name, ...args) {
@@ -27525,6 +27714,6 @@ async function createContext(options = {}) {
27525
27714
  return new Context(config2, settings, identity, options, projectRoot);
27526
27715
  }
27527
27716
 
27528
- export { ChangeAlreadyAppliedError, ChangeNotAppliedError, ChangeNotFoundError, ChangeOrphanedError, ChangeValidationError, ChangesNamespace, Context, DbNamespace, DtNamespace, ImpersonationError, LockAcquireError, LockExpiredError, LockNamespace, ManifestReferenceError, NoormOps, ProtectedConfigError, RequireTestError, RunNamespace, SecretsNamespace, TemplatesNamespace, TransferNamespace, UtilsNamespace, VaultNamespace, createContext };
27717
+ export { ChangeAlreadyAppliedError, ChangeNotAppliedError, ChangeNotFoundError, ChangeOrphanedError, ChangeValidationError, ChangesNamespace, Context, DbNamespace, DtNamespace, ImpersonationError, LockAcquireError, LockExpiredError, LockNamespace, ManifestReferenceError, NoormOps, ProtectedConfigError, RequireTestError, RunNamespace, SecretsNamespace, TemplatesNamespace, TransferNamespace, UtilsNamespace, VaultNamespace, createContext, tvp };
27529
27718
  //# sourceMappingURL=index.js.map
27530
27719
  //# sourceMappingURL=index.js.map