From 7dd8111b5b4f26353a163fbe86db1ef22b6ad053 Mon Sep 17 00:00:00 2001 From: Benjamin Toby Date: Sat, 9 Nov 2024 07:09:00 +0100 Subject: [PATCH] Update Types --- package-shared/types/index.d.ts | 21 +++++++++++++-------- package.json | 2 +- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/package-shared/types/index.d.ts b/package-shared/types/index.d.ts index 9ab5ad3..d9dd402 100644 --- a/package-shared/types/index.d.ts +++ b/package-shared/types/index.d.ts @@ -1174,26 +1174,31 @@ export type AuthFetchQuery = ServerQueryParam & { [key: string]: string | number | { [key: string]: any }; }; -export type ServerQueryParamsJoin = { +export type ServerQueryParamsJoin< + Table extends string = string, + Field extends object = { [key: string]: any } +> = { joinType: "INNER JOIN" | "JOIN" | "LEFT JOIN" | "RIGHT JOIN"; - tableName: string; + tableName: Table; match?: - | ServerQueryParamsJoinMatchObject - | ServerQueryParamsJoinMatchObject[]; + | ServerQueryParamsJoinMatchObject + | ServerQueryParamsJoinMatchObject[]; selectFields?: ( - | string + | keyof Field | { - field: string; + field: keyof Field; alias?: string; } )[]; }; -export type ServerQueryParamsJoinMatchObject = { +export type ServerQueryParamsJoinMatchObject< + Field extends object = { [key: string]: any } +> = { /** Field name from the **Root Table** */ source: string | ServerQueryParamsJoinMatchSourceTargetObject; /** Field name from the **Join Table** */ - target: string | ServerQueryParamsJoinMatchSourceTargetObject; + target: keyof Field | ServerQueryParamsJoinMatchSourceTargetObject; }; export type ServerQueryParamsJoinMatchSourceTargetObject = { diff --git a/package.json b/package.json index 818b107..5404cc6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@moduletrace/datasquirel", - "version": "2.5.6", + "version": "2.5.7", "description": "Cloud-based SQL data management tool", "main": "index.js", "bin": {