Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

kmore

Package Overview
Dependencies
Maintainers
1
Versions
272
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kmore - npm Package Compare versions

Comparing version 29.0.2 to 30.0.0

3

dist/lib/config.d.ts

@@ -1,4 +0,5 @@

import { KmoreEvent } from './types.js';
import type { KmoreEvent, KnexConfig } from './types.js';
export declare const defaultPropDescriptor: PropertyDescriptor;
export declare const initKmoreEvent: KmoreEvent;
export declare const initialConfig: Omit<KnexConfig, 'client' | 'connection'>;
//# sourceMappingURL=config.d.ts.map

@@ -0,1 +1,2 @@

import { postProcessResponse, wrapIdentifier } from './helper.js';
export const defaultPropDescriptor = {

@@ -20,2 +21,9 @@ configurable: false,

};
export const initialConfig = {
acquireConnectionTimeout: 60000,
debug: false,
pool: { min: 0, max: 30 },
postProcessResponse,
wrapIdentifier,
};
//# sourceMappingURL=config.js.map

@@ -1,5 +0,6 @@

import { RecordCamelKeys, RecordSnakeKeys } from '@waiting/shared-types';
import { RecordCamelKeys, RecordPascalKeys, RecordSnakeKeys } from '@waiting/shared-types';
import type { Knex } from 'knex';
import { KnexConfig } from './types.js';
import { CaseType, KnexConfig, QueryContext } from './types.js';
export declare function getCurrentTime(dbh: Knex, clientType: KnexConfig['client']): Promise<string>;
export declare function postProcessResponse<T extends PostProcessInput = PostProcessInput>(result: T, queryContext?: QueryContext): T | PostProcessRespRet<T, QueryContext['caseConvert']>;
export declare type PostProcessPlain = number | string | undefined | null | boolean;

@@ -9,13 +10,21 @@ export declare type PostProcessRecord = Record<string, PostProcessPlain> | object;

export declare type PostProcessInput = PostProcessPlain | PostProcessRecord | PostProcessArray;
export declare type PostProcessRespRet<T extends PostProcessInput> = T extends PostProcessPlain ? T : T extends PostProcessArray ? PostProcessArray : T extends PostProcessRecord ? RecordCamelKeys<T> : never;
export declare type PostProcessRespRet<T extends PostProcessInput, CaseConvert extends CaseType | undefined> = T extends PostProcessPlain ? T : T extends PostProcessArray ? PostProcessArray : T extends PostProcessRecord ? PostProcessRecordCaseConvert<T, CaseConvert> : never;
declare type PostProcessRecordCaseConvert<T extends PostProcessRecord, CaseConvert extends CaseType | undefined> = CaseConvert extends CaseType.camel ? RecordCamelKeys<T> : CaseConvert extends CaseType.pascal ? RecordPascalKeys<T> : CaseConvert extends CaseType.snake ? RecordSnakeKeys<T> : T;
/**
* Convert keys of result to camelcase, if input is object
*/
export declare function postProcessResponseToCamel<T extends PostProcessInput = PostProcessInput>(result: T, _queryContext?: unknown): PostProcessRespRet<T>;
export declare function postProcessResponseToCamel<T extends PostProcessInput = PostProcessInput>(result: T, _queryContext?: QueryContext): PostProcessRespRet<T, CaseType.camel>;
/**
* Convert keys of result to PascalCase, if input is object
*/
/**
* Convert keys of result to snake_case, if input is object
*/
export declare function postProcessResponseToSnake<T extends PostProcessInput = PostProcessInput>(result: T, _queryContext?: QueryContext): PostProcessRespRet<T, CaseType.snake>;
export declare function genCamelKeysFrom<From extends PostProcessRecord>(input: From): RecordCamelKeys<From, '_'>;
export declare function genSnakeKeysFrom<From>(input: From): RecordSnakeKeys<From, '_'>;
export declare function genSnakeKeysFrom<From extends PostProcessRecord>(input: From): RecordSnakeKeys<From, '_'>;
/**
* Convert identifier (field) to snakecase
*/
export declare function wrapIdentifier(value: string, origImpl: (input: string) => string, _queryContext: unknown): string;
export declare function wrapIdentifier(value: string, origImpl: (input: string) => string, queryContext?: QueryContext): string;
/**

@@ -25,2 +34,3 @@ * @description only one level

export declare function mergeDoWithInitData<T extends Record<string, unknown> | object>(initDoData: T, input?: Record<string, unknown> | object): T;
export {};
//# sourceMappingURL=helper.d.ts.map

@@ -1,4 +0,6 @@

import { camelToSnake, camelKeys, snakeKeys, } from '@waiting/shared-core';
import { camelToSnake, camelKeys,
// pascalCase,
snakeKeys, } from '@waiting/shared-core';
// import keysDto2DoSnake from 'snakecase-keys'
import { EnumClient } from './types.js';
import { CaseType, EnumClient } from './types.js';
export async function getCurrentTime(dbh, clientType) {

@@ -32,2 +34,22 @@ if (typeof clientType === 'string' && clientType) {

}
export function postProcessResponse(result, queryContext) {
if (!queryContext) {
return result;
}
const { caseConvert } = queryContext;
if (!caseConvert) {
return result;
}
switch (caseConvert) {
case CaseType.camel:
return postProcessResponseToCamel(result, queryContext);
case CaseType.pascal:
throw Error('Not implemented yet for pascal case conversion');
// return postProcessResponseToPascal(result, queryContext)
case CaseType.snake:
return postProcessResponseToSnake(result, queryContext);
default:
return result;
}
}
/**

@@ -38,3 +60,3 @@ * Convert keys of result to camelcase, if input is object

if (Array.isArray(result)) {
const ret = result.map(row => postProcessResponseToCamel(row));
const ret = result.map(row => postProcessResponseToCamel(row, _queryContext));
return ret;

@@ -48,7 +70,42 @@ }

}
/**
* Convert keys of result to PascalCase, if input is object
*/
// export function postProcessResponseToPascal<T extends PostProcessInput = PostProcessInput>(
// result: T,
// _queryContext?: QueryContext,
// ): PostProcessRespRet<T, CaseType.pascal> {
// if (Array.isArray(result)) {
// const ret = result.map(row => postProcessResponseToCamel(row, _queryContext))
// return ret as PostProcessRespRet<T, CaseType.pascal>
// }
// else if (typeof result === 'object' && result) {
// const ret = genPascalKeysFrom(result)
// return ret as PostProcessRespRet<T, CaseType.pascal>
// }
// return result as PostProcessRespRet<T, CaseType.pascal>
// }
/**
* Convert keys of result to snake_case, if input is object
*/
export function postProcessResponseToSnake(result, _queryContext) {
if (Array.isArray(result)) {
const ret = result.map(row => postProcessResponseToCamel(row, _queryContext));
return ret;
}
else if (typeof result === 'object' && result) {
const ret = genSnakeKeysFrom(result);
return ret;
}
return result;
}
export function genCamelKeysFrom(input) {
return camelKeys(input);
}
// function genPascalKeysFrom<From extends PostProcessRecord>(
// input: From,
// ): RecordPascalKeys<From, '_'> {
// return pascalCase(input)
// }
export function genSnakeKeysFrom(input) {
// return keysDto2DoSnake(input)
return snakeKeys(input);

@@ -59,4 +116,10 @@ }

*/
export function wrapIdentifier(value, origImpl, _queryContext) {
return origImpl(camelToSnake(value));
export function wrapIdentifier(value, origImpl, queryContext) {
if (!queryContext
|| !queryContext.caseConvert
|| queryContext.caseConvert === CaseType.none) {
return origImpl(value);
}
const ret = origImpl(camelToSnake(value));
return ret;
}

@@ -63,0 +126,0 @@ /**

@@ -0,1 +1,2 @@

export * from './config.js';
export * from './helper.js';

@@ -2,0 +3,0 @@ export * from './kmore.js';

@@ -0,1 +1,2 @@

export * from './config.js';
export * from './helper.js';

@@ -2,0 +3,0 @@ export * from './kmore.js';

import type { DbDict } from 'kmore-types';
import type { Knex } from 'knex';
import { DbQueryBuilder, KmoreEvent, KnexConfig, QuerySpanInfo } from './types.js';
import { CaseType, DbQueryBuilder, KmoreEvent, KnexConfig, QuerySpanInfo } from './types.js';
export declare class Kmore<D = unknown> {

@@ -9,3 +9,5 @@ readonly config: KnexConfig;

instanceId: string | symbol;
readonly refTables: DbQueryBuilder<D, 'ref_'>;
readonly refTables: DbQueryBuilder<D, 'ref_', CaseType.none>;
readonly camelTables: DbQueryBuilder<D, 'ref_', CaseType.camel>;
readonly snakeTables: DbQueryBuilder<D, 'ref_', CaseType.snake>;
/**

@@ -37,4 +39,4 @@ * Generics parameter, do NOT access as variable!

unsubscribe(): void;
protected createRefTables(dbh: Knex, prefix: string): DbQueryBuilder<D>;
protected extRefTableFnProperty(dbh: Knex, refName: string): Knex.QueryBuilder;
protected createRefTables<P extends string>(dbh: Knex, prefix: P, caseConvert: CaseType): DbQueryBuilder<D, P, CaseType>;
protected extRefTableFnProperty(dbh: Knex, refName: string, caseConvert: CaseType): Knex.QueryBuilder;
}

@@ -49,4 +51,4 @@ export interface KmoreFactoryOpts<D> {

export declare type EventCallback = (event: KmoreEvent) => void;
export declare function kmoreFactory<D>(options: KmoreFactoryOpts<D>, enableTracing?: boolean): Kmore<D>;
export declare function kmoreFactory<D extends object>(options: KmoreFactoryOpts<D>, enableTracing?: boolean): Kmore<D>;
export declare function createDbh(knexConfig: KnexConfig, enableTracing?: boolean): Knex;
//# sourceMappingURL=kmore.d.ts.map
/* eslint-disable import/no-extraneous-dependencies */
import assert from 'assert';
import { TracerLog, TracerTag, } from '@mw-components/jaeger';

@@ -8,2 +9,3 @@ import { genISO8601String, humanMemoryUsage, } from '@waiting/shared-core';

import { bindOnQuery, bindOnQueryError, bindOnQueryResp, globalSubject } from './event.js';
import { CaseType, } from './types.js';
export class Kmore {

@@ -15,2 +17,5 @@ config;

refTables;
camelTables;
// readonly pascalTables: DbQueryBuilder<D, 'ref_', CaseType.pascal>
snakeTables;
/**

@@ -46,3 +51,6 @@ * Generics parameter, do NOT access as variable!

this.instanceId = instanceId;
this.refTables = this.createRefTables(this.dbh, 'ref_');
this.refTables = this.createRefTables(this.dbh, 'ref_', CaseType.none);
this.camelTables = this.createRefTables(this.dbh, 'ref_', CaseType.camel);
// this.pascalTables = this.createRefTables<'ref_'>(this.dbh, 'ref_', CaseType.pascal)
this.snakeTables = this.createRefTables(this.dbh, 'ref_', CaseType.snake);
}

@@ -67,3 +75,3 @@ unsubscribe() {

}
createRefTables(dbh, prefix) {
createRefTables(dbh, prefix, caseConvert) {
const rb = {};

@@ -79,3 +87,3 @@ if (!this.dict || !this.dict.tables || !Object.keys(this.dict.tables).length) {

value: () => {
return this.extRefTableFnProperty(dbh, refName);
return this.extRefTableFnProperty(dbh, refName, caseConvert);
}, // must dynamically!!

@@ -90,4 +98,8 @@ });

}
extRefTableFnProperty(dbh, refName) {
const refTable = dbh(refName);
extRefTableFnProperty(dbh, refName, caseConvert) {
assert(caseConvert, 'caseConvert must be defined');
const opts = {
caseConvert,
};
const refTable = dbh(refName).queryContext(opts);
return refTable;

@@ -94,0 +106,0 @@ }

@@ -0,1 +1,2 @@

import { RecordCamelKeys, RecordPascalKeys, RecordSnakeKeys } from '@waiting/shared-types';
import type { Knex } from 'knex';

@@ -12,5 +13,15 @@ import { Span } from 'opentracing';

}
export declare type DbQueryBuilder<D, Prefix extends string = 'ref_'> = {
[tb in keyof D as `${Prefix}${tb & string}`]: TbQueryBuilder<D[tb]>;
export declare enum CaseType {
camel = "camel",
pascal = "pascal",
snake = "snake",
none = "none"
}
export declare type DbQueryBuilder<D, Prefix extends string, CaseConvert extends CaseType> = {
[tb in keyof D as `${Prefix}${tb & string}`]: CaseConvert extends CaseType.camel ? TbQueryBuilder<RecordCamelKeys<D[tb]>> : CaseConvert extends CaseType.snake ? TbQueryBuilder<RecordSnakeKeys<D[tb]>> : CaseConvert extends CaseType.pascal ? TbQueryBuilder<RecordPascalKeys<D[tb]>> : TbQueryBuilder<D[tb]>;
};
export interface BuilderInput {
ctx?: unknown;
caseConvert?: CaseType | undefined;
}
export declare type TbQueryBuilder<TRecord> = () => Knex.QueryBuilder<TRecord, TRecord[]>;

@@ -42,2 +53,5 @@ export interface KmoreEvent<T = unknown> {

}
export interface QueryContext {
caseConvert?: CaseType;
}
export interface OnQueryData {

@@ -44,0 +58,0 @@ __knexUid: string;

@@ -10,2 +10,9 @@ export var EnumClient;

})(EnumClient = EnumClient || (EnumClient = {}));
export var CaseType;
(function (CaseType) {
CaseType["camel"] = "camel";
CaseType["pascal"] = "pascal";
CaseType["snake"] = "snake";
CaseType["none"] = "none";
})(CaseType = CaseType || (CaseType = {}));
//# sourceMappingURL=types.js.map
{
"name": "kmore",
"author": "waiting",
"version": "29.0.2",
"version": "30.0.0",
"description": "A SQL query builder based on knex with powerful TypeScript type support",

@@ -13,2 +13,3 @@ "keywords": [

"postgresql",
"pg",
"oracle",

@@ -47,3 +48,3 @@ "AST",

"cross-env": "7",
"kmore-types": "^29.0.1",
"kmore-types": "^30.0.0",
"knex": "^2.1.0",

@@ -79,3 +80,3 @@ "pg": "^8.7.3"

},
"gitHead": "a45cb61bf5744d6acca4913e572dda452b24de56"
"gitHead": "ee1581dda7814045e634f79094d08c1bf9e74b13"
}

@@ -1,2 +0,3 @@

import { KmoreEvent } from './types.js'
import { postProcessResponse, wrapIdentifier } from './helper.js'
import type { KmoreEvent, KnexConfig } from './types.js'

@@ -26,1 +27,9 @@

export const initialConfig: Omit<KnexConfig, 'client' | 'connection'> = {
acquireConnectionTimeout: 60000,
debug: false,
pool: { min: 0, max: 30 },
postProcessResponse,
wrapIdentifier,
}
import {
camelToSnake,
camelKeys,
// pascalCase,
snakeKeys,
} from '@waiting/shared-core'
import { RecordCamelKeys, RecordSnakeKeys } from '@waiting/shared-types'
import { RecordCamelKeys, RecordPascalKeys, RecordSnakeKeys } from '@waiting/shared-types'
// import keysDoToDtoCamel from 'camelcase-keys'

@@ -12,3 +13,3 @@ // eslint-disable-next-line import/no-extraneous-dependencies

import { EnumClient, KnexConfig } from './types.js'
import { CaseType, EnumClient, KnexConfig, QueryContext } from './types.js'

@@ -63,2 +64,30 @@

export function postProcessResponse<T extends PostProcessInput = PostProcessInput>(
result: T,
queryContext?: QueryContext,
): T | PostProcessRespRet<T, QueryContext['caseConvert']> {
if (! queryContext) {
return result
}
const { caseConvert } = queryContext
if (! caseConvert) {
return result
}
switch (caseConvert) {
case CaseType.camel:
return postProcessResponseToCamel(result, queryContext)
case CaseType.pascal:
throw Error('Not implemented yet for pascal case conversion')
// return postProcessResponseToPascal(result, queryContext)
case CaseType.snake:
return postProcessResponseToSnake(result, queryContext)
default:
return result
}
}
export type PostProcessPlain = number | string | undefined | null | boolean

@@ -68,9 +97,18 @@ export type PostProcessRecord = Record<string, PostProcessPlain> | object

export type PostProcessInput = PostProcessPlain | PostProcessRecord | PostProcessArray
export type PostProcessRespRet<T extends PostProcessInput> = T extends PostProcessPlain
? T
: T extends PostProcessArray // before PostProcessRecord
? PostProcessArray
: T extends PostProcessRecord
? RecordCamelKeys<T>
: never
export type PostProcessRespRet<T extends PostProcessInput, CaseConvert extends CaseType | undefined>
= T extends PostProcessPlain
? T
: T extends PostProcessArray // condition before PostProcessRecord
? PostProcessArray
: T extends PostProcessRecord // condition after PostProcessArray
? PostProcessRecordCaseConvert<T, CaseConvert>
: never
type PostProcessRecordCaseConvert<T extends PostProcessRecord, CaseConvert extends CaseType | undefined>
= CaseConvert extends CaseType.camel
? RecordCamelKeys<T>
: CaseConvert extends CaseType.pascal
? RecordPascalKeys<T>
: CaseConvert extends CaseType.snake
? RecordSnakeKeys<T>
: T

@@ -82,29 +120,73 @@ /**

result: T,
_queryContext?: unknown,
): PostProcessRespRet<T> {
_queryContext?: QueryContext,
): PostProcessRespRet<T, CaseType.camel> {
if (Array.isArray(result)) {
const ret = result.map(row => postProcessResponseToCamel(row))
return ret as PostProcessRespRet<T>
const ret = result.map(row => postProcessResponseToCamel(row, _queryContext))
return ret as PostProcessRespRet<T, CaseType.camel>
}
else if (typeof result === 'object' && result) {
const ret = genCamelKeysFrom(result)
return ret as PostProcessRespRet<T>
return ret as PostProcessRespRet<T, CaseType.camel>
}
return result as PostProcessRespRet<T>
return result as PostProcessRespRet<T, CaseType.camel>
}
/**
* Convert keys of result to PascalCase, if input is object
*/
// export function postProcessResponseToPascal<T extends PostProcessInput = PostProcessInput>(
// result: T,
// _queryContext?: QueryContext,
// ): PostProcessRespRet<T, CaseType.pascal> {
// if (Array.isArray(result)) {
// const ret = result.map(row => postProcessResponseToCamel(row, _queryContext))
// return ret as PostProcessRespRet<T, CaseType.pascal>
// }
// else if (typeof result === 'object' && result) {
// const ret = genPascalKeysFrom(result)
// return ret as PostProcessRespRet<T, CaseType.pascal>
// }
// return result as PostProcessRespRet<T, CaseType.pascal>
// }
/**
* Convert keys of result to snake_case, if input is object
*/
export function postProcessResponseToSnake<T extends PostProcessInput = PostProcessInput>(
result: T,
_queryContext?: QueryContext,
): PostProcessRespRet<T, CaseType.snake> {
if (Array.isArray(result)) {
const ret = result.map(row => postProcessResponseToCamel(row, _queryContext))
return ret as PostProcessRespRet<T, CaseType.snake>
}
else if (typeof result === 'object' && result) {
const ret = genSnakeKeysFrom(result)
return ret as PostProcessRespRet<T, CaseType.snake>
}
return result as PostProcessRespRet<T, CaseType.snake>
}
export function genCamelKeysFrom<From extends PostProcessRecord>(
input: From,
): RecordCamelKeys<From, '_'> {
return camelKeys(input)
}
export function genSnakeKeysFrom<From>(
// function genPascalKeysFrom<From extends PostProcessRecord>(
// input: From,
// ): RecordPascalKeys<From, '_'> {
// return pascalCase(input)
// }
export function genSnakeKeysFrom<From extends PostProcessRecord>(
input: From,
): RecordSnakeKeys<From, '_'> {
// return keysDto2DoSnake(input)
return snakeKeys(input)

@@ -119,5 +201,13 @@ }

origImpl: (input: string) => string,
_queryContext: unknown,
queryContext?: QueryContext,
): string {
return origImpl(camelToSnake(value))
if (! queryContext
|| ! queryContext.caseConvert
|| queryContext.caseConvert === CaseType.none) {
return origImpl(value)
}
const ret = origImpl(camelToSnake(value))
return ret
}

@@ -124,0 +214,0 @@

export * from './config.js'
export * from './helper.js'

@@ -3,0 +4,0 @@ export * from './kmore.js'

/* eslint-disable import/no-extraneous-dependencies */
import assert from 'assert'
import {

@@ -19,2 +21,3 @@ SpanLogInput,

import {
CaseType,
DbQueryBuilder,

@@ -27,2 +30,3 @@ KmoreEvent,

OnQueryRespRaw,
QueryContext,
QueryResponse,

@@ -34,4 +38,8 @@ QuerySpanInfo,

export class Kmore<D = unknown> {
readonly refTables: DbQueryBuilder<D, 'ref_'>
readonly refTables: DbQueryBuilder<D, 'ref_', CaseType.none>
readonly camelTables: DbQueryBuilder<D, 'ref_', CaseType.camel>
// readonly pascalTables: DbQueryBuilder<D, 'ref_', CaseType.pascal>
readonly snakeTables: DbQueryBuilder<D, 'ref_', CaseType.snake>
/**

@@ -73,3 +81,6 @@ * Generics parameter, do NOT access as variable!

this.refTables = this.createRefTables(this.dbh, 'ref_')
this.refTables = this.createRefTables<'ref_'>(this.dbh, 'ref_', CaseType.none)
this.camelTables = this.createRefTables<'ref_'>(this.dbh, 'ref_', CaseType.camel)
// this.pascalTables = this.createRefTables<'ref_'>(this.dbh, 'ref_', CaseType.pascal)
this.snakeTables = this.createRefTables<'ref_'>(this.dbh, 'ref_', CaseType.snake)
}

@@ -97,5 +108,10 @@

protected createRefTables(dbh: Knex, prefix: string): DbQueryBuilder<D> {
const rb = {} as DbQueryBuilder<D>
protected createRefTables<P extends string>(
dbh: Knex,
prefix: P,
caseConvert: CaseType,
): DbQueryBuilder<D, P, CaseType> {
const rb = {} as DbQueryBuilder<D, P, CaseType>
if (! this.dict || ! this.dict.tables || ! Object.keys(this.dict.tables).length) {

@@ -111,3 +127,3 @@ console.info('Kmore:createRefTables() this.dict or this.dict.tables empty')

value: () => {
return this.extRefTableFnProperty(dbh, refName)
return this.extRefTableFnProperty(dbh, refName, caseConvert)
}, // must dynamically!!

@@ -120,2 +136,3 @@ })

})
})

@@ -129,5 +146,11 @@

refName: string,
caseConvert: CaseType,
): Knex.QueryBuilder {
const refTable = dbh(refName)
assert(caseConvert, 'caseConvert must be defined')
const opts: QueryContext = {
caseConvert,
}
const refTable = dbh(refName).queryContext(opts)
return refTable

@@ -154,3 +177,3 @@ }

export function kmoreFactory<D>(
export function kmoreFactory<D extends object>(
options: KmoreFactoryOpts<D>,

@@ -178,2 +201,3 @@ enableTracing = false,

let inst = _knex(knexConfig)
if (enableTracing) {

@@ -180,0 +204,0 @@ inst = inst

/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable import/no-extraneous-dependencies */
// import { FullTableModelFromDictAlias } from '@waiting/shared-types'
import { RecordCamelKeys, RecordPascalKeys, RecordSnakeKeys } from '@waiting/shared-types'
import type { Knex } from 'knex'

@@ -19,9 +19,42 @@ import { Span } from 'opentracing'

export type DbQueryBuilder<D, Prefix extends string = 'ref_'> = {
export enum CaseType {
camel = 'camel',
pascal = 'pascal',
snake = 'snake',
none = 'none'
}
export type DbQueryBuilder<
D,
Prefix extends string,
CaseConvert extends CaseType
> = {
/** ref_tb_name: () => knex('tb_name') */
[tb in keyof D as `${Prefix}${tb & string}`]: TbQueryBuilder<D[tb]>
// [tb in keyof D as `${Prefix}${tb & string}`]: TbQueryBuilder<D[tb]>
[tb in keyof D as `${Prefix}${tb & string}`]: CaseConvert extends CaseType.camel
? TbQueryBuilder<RecordCamelKeys<D[tb]>>
: CaseConvert extends CaseType.snake
? TbQueryBuilder<RecordSnakeKeys<D[tb]>>
: CaseConvert extends CaseType.pascal
? TbQueryBuilder<RecordPascalKeys<D[tb]>>
: TbQueryBuilder<D[tb]>
}
export interface BuilderInput {
ctx?: unknown
caseConvert?: CaseType | undefined
}
export type TbQueryBuilder<TRecord> = () => Knex.QueryBuilder<TRecord, TRecord[]>
// export type TbQueryBuilder<TRecord>
// = <CaseConvert extends CaseType = CaseType.none>(caseConvert?: CaseConvert)
// => CaseConvert extends CaseType.camel
// ? Knex.QueryBuilder<RecordCamelKeys<TRecord>, TRecord[]>
// : CaseConvert extends CaseType.snake
// ? Knex.QueryBuilder<RecordSnakeKeys<TRecord>, TRecord[]>
// : CaseConvert extends CaseType.pascal
// ? Knex.QueryBuilder<RecordPascalKeys<TRecord>, TRecord[]>
// : Knex.QueryBuilder<TRecord, TRecord[]>
// export type QueryBuilderExt<TRecord, TResult = TRecord[]>

@@ -61,2 +94,6 @@ // = Knex.QueryBuilder<TRecord, TResult>

export interface QueryContext {
caseConvert?: CaseType
}
export interface OnQueryData {

@@ -63,0 +100,0 @@ __knexUid: string // "__knexUid3"

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc