@noormdev/sdk 1.0.0-alpha.26 → 1.0.0-alpha.27
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 +16 -9
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -3928,15 +3928,17 @@ export declare class Context<DB = unknown, Procs = object, Funcs = object, Tvfs
|
|
|
3928
3928
|
*
|
|
3929
3929
|
* @example
|
|
3930
3930
|
* ```typescript
|
|
3931
|
+
* interface CheckoutItem { Type: string; ReferenceNo: number; Qty: number }
|
|
3932
|
+
*
|
|
3931
3933
|
* interface MyProcs {
|
|
3932
|
-
* 'Checkout_trx': [{ Party: number;
|
|
3934
|
+
* 'Checkout_trx': [{ Party: number; Items: TvpValue<CheckoutItem> }, void];
|
|
3933
3935
|
* }
|
|
3934
3936
|
* ```
|
|
3935
3937
|
*/
|
|
3936
|
-
export interface TvpValue {
|
|
3938
|
+
export interface TvpValue<T extends Record<string, unknown> = Record<string, unknown>> {
|
|
3937
3939
|
readonly __noorm_tvp: true;
|
|
3938
3940
|
readonly typeName: string;
|
|
3939
|
-
readonly rows: ReadonlyArray<
|
|
3941
|
+
readonly rows: ReadonlyArray<T>;
|
|
3940
3942
|
}
|
|
3941
3943
|
/**
|
|
3942
3944
|
* Create a Table-Valued Parameter for MSSQL stored procedure calls.
|
|
@@ -3949,21 +3951,26 @@ export interface TvpValue {
|
|
|
3949
3951
|
*
|
|
3950
3952
|
* @example
|
|
3951
3953
|
* ```typescript
|
|
3952
|
-
*
|
|
3954
|
+
* interface CheckoutItem { Type: number; ReferenceNo: number; Qty: number }
|
|
3955
|
+
*
|
|
3956
|
+
* // Row type is inferred — returns TvpValue<CheckoutItem>
|
|
3957
|
+
* const items: CheckoutItem[] = [
|
|
3958
|
+
* { Type: 1, ReferenceNo: 100, Qty: 5 },
|
|
3959
|
+
* { Type: 2, ReferenceNo: 200, Qty: 3 },
|
|
3960
|
+
* ];
|
|
3961
|
+
*
|
|
3962
|
+
* // Named params — type-checked against TvpValue<CheckoutItem>
|
|
3953
3963
|
* await ctx.proc('Checkout_trx', {
|
|
3954
3964
|
* Party: 1,
|
|
3955
3965
|
* PaymentMethod: 2,
|
|
3956
|
-
* Items: tvp('CheckoutItems',
|
|
3957
|
-
* { Type: 1, ReferenceNo: 100, Qty: 5 },
|
|
3958
|
-
* { Type: 2, ReferenceNo: 200, Qty: 3 },
|
|
3959
|
-
* ]),
|
|
3966
|
+
* Items: tvp('CheckoutItems', items),
|
|
3960
3967
|
* });
|
|
3961
3968
|
*
|
|
3962
3969
|
* // Positional params
|
|
3963
3970
|
* await ctx.proc('Checkout_trx', [1, 2, tvp('CheckoutItems', items)]);
|
|
3964
3971
|
* ```
|
|
3965
3972
|
*/
|
|
3966
|
-
export declare function tvp(typeName: string, rows:
|
|
3973
|
+
export declare function tvp<T extends Record<string, unknown>>(typeName: string, rows: T[]): TvpValue<T>;
|
|
3967
3974
|
/**
|
|
3968
3975
|
* Error thrown when requireTest is enabled but config.isTest is false.
|
|
3969
3976
|
*
|
package/dist/index.js
CHANGED
|
@@ -23532,7 +23532,8 @@ async function teardownSchema(db, dialect, options = {}) {
|
|
|
23532
23532
|
statements.push(ops.dropProcedure(proc.name, proc.schema));
|
|
23533
23533
|
}
|
|
23534
23534
|
}
|
|
23535
|
-
|
|
23535
|
+
const skipTypesDueToKeptRoutines = dialect === "mssql" && (options.keepFunctions || options.keepProcedures);
|
|
23536
|
+
if (!options.keepTypes && !skipTypesDueToKeptRoutines) {
|
|
23536
23537
|
const sortedTypes = [...types].sort((a, b) => {
|
|
23537
23538
|
if (a.kind === "composite" && b.kind !== "composite") return -1;
|
|
23538
23539
|
if (a.kind !== "composite" && b.kind === "composite") return 1;
|