ts-sql-query
Advanced tools
Comparing version 1.13.0 to 1.14.0
@@ -1,15 +0,34 @@ | ||
import { Column } from "../utils/Column"; | ||
import type { ITableOrView } from "../utils/ITableOrView"; | ||
import { Column, OptionalColumn } from "../utils/Column"; | ||
declare type OnlyStringKey<KEY> = KEY extends string ? KEY : never; | ||
export declare function prefixCapitalized<O extends object, PREFIX extends string>(obj: O, prefix: PREFIX): { | ||
[K in OnlyStringKey<keyof O> as `${PREFIX}${Capitalize<K>}`]: O[K]; | ||
[K in OnlyStringKey<keyof O> as `${PREFIX}${Capitalize<K>}`]: O[K]; | ||
}; | ||
export declare function prefixMapForSplitCapitalized<O extends object, PREFIX extends string>(obj: O, prefix: PREFIX): { | ||
[K in OnlyStringKey<keyof O> as K]: `${PREFIX}${Capitalize<K>}`; | ||
[K in OnlyStringKey<keyof O> as K]: `${PREFIX}${Capitalize<K>}`; | ||
}; | ||
declare type CapitalizedGuided<PREFIX extends string, KEY extends string, REFERENCE extends object> = KEY extends keyof REFERENCE ? (REFERENCE[KEY] extends Column ? (REFERENCE[KEY] extends OptionalColumn ? `${PREFIX}${Capitalize<KEY>}` : `${PREFIX}${Capitalize<KEY>}!`) : `${PREFIX}${Capitalize<KEY>}`) : `${PREFIX}${Capitalize<KEY>}`; | ||
export declare function prefixMapForGuidedSplitCapitalized<O extends object, R extends ITableOrView<any> | { | ||
[KEY in keyof O]?: Column; | ||
}, PREFIX extends string>(obj: O, reference: R, prefix: PREFIX): { | ||
[K in OnlyStringKey<keyof O> as K]: CapitalizedGuided<PREFIX, K, R>; | ||
}; | ||
declare type NameGuided<KEY extends string, REFERENCE extends object> = KEY extends keyof REFERENCE ? (REFERENCE[KEY] extends Column ? (REFERENCE[KEY] extends OptionalColumn ? KEY : `${KEY}!`) : KEY) : KEY; | ||
export declare function mapForGuidedSplit<O extends object, R extends ITableOrView<any> | { | ||
[KEY in keyof O]?: Column; | ||
}>(obj: O, reference: R): { | ||
[K in OnlyStringKey<keyof O> as K]: NameGuided<K, R>; | ||
}; | ||
export declare function prefixDotted<O extends object, PREFIX extends string>(obj: O, prefix: PREFIX): { | ||
[K in OnlyStringKey<keyof O> as `${PREFIX}.${K}`]-?: O[K]; | ||
[K in OnlyStringKey<keyof O> as `${PREFIX}.${K}`]-?: O[K]; | ||
}; | ||
export declare function prefixMapForSplitDotted<O extends object, PREFIX extends string>(obj: O, prefix: PREFIX): { | ||
[K in OnlyStringKey<keyof O> as K]-?: `${PREFIX}.${K}`; | ||
[K in OnlyStringKey<keyof O> as K]-?: `${PREFIX}.${K}`; | ||
}; | ||
declare type DottedGuided<PREFIX extends string, KEY extends string, REFERENCE extends object> = KEY extends keyof REFERENCE ? (REFERENCE[KEY] extends Column ? (REFERENCE[KEY] extends OptionalColumn ? `${PREFIX}.${KEY}` : `${PREFIX}.${KEY}!`) : `${PREFIX}.${KEY}`) : `${PREFIX}.${KEY}`; | ||
export declare function prefixMapForGuidedSplitDotted<O extends object, R extends ITableOrView<any> | { | ||
[KEY in keyof O]?: Column; | ||
}, PREFIX extends string>(obj: O, reference: R, prefix: PREFIX): { | ||
[K in OnlyStringKey<keyof O> as K]: DottedGuided<PREFIX, K, R>; | ||
}; | ||
declare type ColumnKeys<O extends object> = { | ||
@@ -16,0 +35,0 @@ [K in keyof O]-?: O[K] extends Column ? K : never; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.extractColumnsFrom = exports.prefixMapForSplitDotted = exports.prefixDotted = exports.prefixMapForSplitCapitalized = exports.prefixCapitalized = void 0; | ||
exports.extractColumnsFrom = exports.prefixMapForGuidedSplitDotted = exports.prefixMapForSplitDotted = exports.prefixDotted = exports.mapForGuidedSplit = exports.prefixMapForGuidedSplitCapitalized = exports.prefixMapForSplitCapitalized = exports.prefixCapitalized = void 0; | ||
const Column_1 = require("../utils/Column"); | ||
@@ -27,2 +27,36 @@ function prefixCapitalized(obj, prefix) { | ||
exports.prefixMapForSplitCapitalized = prefixMapForSplitCapitalized; | ||
function prefixMapForGuidedSplitCapitalized(obj, reference, prefix) { | ||
if (!obj) { | ||
return obj; | ||
} | ||
const result = {}; | ||
for (let key in obj) { | ||
const r = reference[key]; | ||
if (Column_1.isColumn(r) && !Column_1.__getColumnPrivate(r).__isOptional) { | ||
result[key] = prefix + key.substr(0, 1).toUpperCase() + key.substr(1) + '!'; | ||
} | ||
else { | ||
result[key] = prefix + key.substr(0, 1).toUpperCase() + key.substr(1); | ||
} | ||
} | ||
return result; | ||
} | ||
exports.prefixMapForGuidedSplitCapitalized = prefixMapForGuidedSplitCapitalized; | ||
function mapForGuidedSplit(obj, reference) { | ||
if (!obj) { | ||
return obj; | ||
} | ||
const result = {}; | ||
for (let key in obj) { | ||
const r = reference[key]; | ||
if (Column_1.isColumn(r) && !Column_1.__getColumnPrivate(r).__isOptional) { | ||
result[key] = key + '!'; | ||
} | ||
else { | ||
result[key] = key; | ||
} | ||
} | ||
return result; | ||
} | ||
exports.mapForGuidedSplit = mapForGuidedSplit; | ||
function prefixDotted(obj, prefix) { | ||
@@ -50,2 +84,19 @@ if (!obj) { | ||
exports.prefixMapForSplitDotted = prefixMapForSplitDotted; | ||
function prefixMapForGuidedSplitDotted(obj, reference, prefix) { | ||
if (!obj) { | ||
return obj; | ||
} | ||
const result = {}; | ||
for (let key in obj) { | ||
const r = reference[key]; | ||
if (Column_1.isColumn(r) && !Column_1.__getColumnPrivate(r).__isOptional) { | ||
result[key] = prefix + '.' + key + '!'; | ||
} | ||
else { | ||
result[key] = prefix + '.' + key; | ||
} | ||
} | ||
return result; | ||
} | ||
exports.prefixMapForGuidedSplitDotted = prefixMapForGuidedSplitDotted; | ||
function extractColumnsFrom(obj) { | ||
@@ -52,0 +103,0 @@ if (!obj) { |
{ | ||
"name": "ts-sql-query", | ||
"version": "1.13.0", | ||
"version": "1.14.0", | ||
"description": "Type-safe SQL query builder like QueryDSL or JOOQ in Java or Linq in .Net for TypeScript with MariaDB, MySql, Oracle, PostgreSql, Sqlite and SqlServer support.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
1280167
21985