Comparing version 59.5.2 to 59.5.3
@@ -19,3 +19,3 @@ import assert from 'node:assert'; | ||
}; | ||
const outputMaping = pagingOptions.wrapOutput === true | ||
const outputMaping = pagingOptions.wrapOutput | ||
? { ...initPageTypeMaping } | ||
@@ -104,3 +104,3 @@ : void 0; | ||
// @ts-ignore | ||
const method = builder['_method']; | ||
const method = builder._method; | ||
assert(method === 'select', 'autoPaging() can only be called on SELECT queries, .first() not supported'); | ||
@@ -107,0 +107,0 @@ // @ts-ignore |
@@ -25,3 +25,3 @@ import assert from 'node:assert'; | ||
} | ||
return callCbOnStart({ | ||
callCbOnStart({ | ||
...opts, | ||
@@ -31,11 +31,15 @@ builder, | ||
}) | ||
.on('query', (data) => callCbOnQuery({ | ||
...opts, | ||
data, | ||
})) | ||
.on('query-response', (resp, respRaw) => callCbOnQueryResp({ | ||
...opts, | ||
_resp: resp, | ||
respRaw, | ||
})) | ||
.on('query', (data) => { | ||
callCbOnQuery({ | ||
...opts, | ||
data, | ||
}); | ||
}) | ||
.on('query-response', (resp, respRaw) => { | ||
callCbOnQueryResp({ | ||
...opts, | ||
_resp: resp, | ||
respRaw, | ||
}); | ||
}) | ||
.on('query-error', async (err, data) => { | ||
@@ -42,0 +46,0 @@ const trx = kmore.getTrxByKmoreQueryId(kmoreQueryId); |
@@ -44,3 +44,3 @@ /* eslint-disable max-params */ | ||
assert(caseConvert, 'caseConvert must be defined'); | ||
const kmoreQueryId = Symbol(`${kmore.dbId}-${Date.now()}`); | ||
const kmoreQueryId = Symbol(`${kmore.dbId}-${Date.now().toString()}`); | ||
// @ts-ignore | ||
@@ -47,0 +47,0 @@ assert(kmore.dbh); |
@@ -17,3 +17,4 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ | ||
event.dbId = options.dbId; | ||
return cb(event, options.ctx); | ||
cb(event, options.ctx); | ||
return; | ||
} | ||
@@ -33,3 +34,4 @@ } | ||
event.dbId = options.dbId; | ||
return cb(event, options.ctx); | ||
cb(event, options.ctx); | ||
return; | ||
} | ||
@@ -49,3 +51,4 @@ } | ||
event.dbId = options.dbId; | ||
return cb(event, options.ctx); | ||
cb(event, options.ctx); | ||
return; | ||
} | ||
@@ -81,3 +84,4 @@ } | ||
case 'query': { | ||
const data = input.data; | ||
const { data } = input; | ||
assert(data, 'data should be set on query event'); | ||
ev.method = data.method ? data.method : ''; | ||
@@ -90,2 +94,3 @@ ev.kUid = data.__knexUid; | ||
const data = input.respRaw; | ||
assert(data, 'data should be set on queryResponse event'); | ||
ev.method = data.method ? data.method : ''; | ||
@@ -99,2 +104,3 @@ ev.command = data.response?.command; | ||
const data = input.exData; | ||
assert(data, 'data should be set on queryError event'); | ||
ev.method = data.method; | ||
@@ -101,0 +107,0 @@ ev.kUid = data.__knexUid; |
@@ -18,3 +18,3 @@ import { RecordCamelKeys, RecordPascalKeys, RecordSnakeKeys } from '@waiting/shared-types'; | ||
/** | ||
* Convert keys of result to camelcase, if input is object | ||
* Convert keys of result to camel case, if input is object | ||
*/ | ||
@@ -21,0 +21,0 @@ export declare function postProcessResponseToCamel<T extends PostProcessInput = PostProcessInput>(result: T, _queryContext?: QueryContext): PostProcessRespRet<T, CaseType.camel>; |
@@ -10,3 +10,5 @@ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ | ||
case EnumClient.pg: | ||
// eslint-disable-next-line no-fallthrough | ||
case EnumClient.pgnative: | ||
// eslint-disable-next-line no-fallthrough | ||
case EnumClient.mysql: | ||
@@ -124,3 +126,3 @@ return parseRespCommon(res); | ||
/** | ||
* Convert keys of result to camelcase, if input is object | ||
* Convert keys of result to camel case, if input is object | ||
*/ | ||
@@ -149,4 +151,4 @@ export function postProcessResponseToCamel(result, _queryContext) { | ||
const { resultNotConvertKeys, resultNeedConvertKeys } = genResultKeysData(row, columns); | ||
const reulst2 = genCamelKeysFrom(resultNeedConvertKeys); | ||
const ret = Object.assign(resultNotConvertKeys, reulst2); | ||
const results2 = genCamelKeysFrom(resultNeedConvertKeys); | ||
const ret = Object.assign(resultNotConvertKeys, results2); | ||
return ret; | ||
@@ -196,4 +198,4 @@ } | ||
const { resultNotConvertKeys, resultNeedConvertKeys } = genResultKeysData(row, columns); | ||
const reulst2 = genSnakeKeysFrom(resultNeedConvertKeys); | ||
const ret = Object.assign(resultNotConvertKeys, reulst2); | ||
const results2 = genSnakeKeysFrom(resultNeedConvertKeys); | ||
const ret = Object.assign(resultNotConvertKeys, results2); | ||
return ret; | ||
@@ -200,0 +202,0 @@ } |
@@ -38,3 +38,3 @@ import assert from 'assert'; | ||
}; | ||
if (wrapOutput === true) { | ||
if (wrapOutput) { | ||
opts.wrapOutput = true; | ||
@@ -41,0 +41,0 @@ } |
@@ -87,6 +87,9 @@ /* eslint-disable @typescript-eslint/no-redundant-type-constituents */ | ||
} | ||
if (ex) { | ||
if (ex instanceof Error) { | ||
return Promise.reject(ex); | ||
} | ||
else { | ||
return Promise.reject(new Error('Kmore Error when executing then()', { cause: ex })); | ||
} | ||
} | ||
//# sourceMappingURL=proxy.get.helper.js.map |
import assert from 'node:assert'; | ||
export function genKmoreTrxId(id, suffix) { | ||
if (!id) { | ||
const str = `trx-${Date.now()}` + (suffix ? `-${suffix}` : ''); | ||
const str = `trx-${Date.now().toString()}` + (suffix ? `-${suffix}` : ''); | ||
return Symbol(str); | ||
@@ -16,3 +16,3 @@ } | ||
assert(key, 'retrieve key from id failed, input should like "Symbol(trx-1234567890)"'); | ||
key2 = `${key}-${Date.now()}`; | ||
key2 = `${key}-${Date.now().toString()}`; | ||
} | ||
@@ -25,3 +25,3 @@ else if (str.startsWith('trx-')) { | ||
} | ||
const key3 = suffix ? `${key2}-${suffix}` : `${key2}-${Date.now()}`; | ||
const key3 = suffix ? `${key2}-${suffix}` : `${key2}-${Date.now().toString()}`; | ||
assert(key3 !== str, 'result should not equal to the input id'); | ||
@@ -28,0 +28,0 @@ return Symbol(key3); |
{ | ||
"name": "kmore", | ||
"author": "waiting", | ||
"version": "59.5.2", | ||
"version": "59.5.3", | ||
"description": "A SQL query builder based on knex with powerful TypeScript type support", | ||
@@ -46,4 +46,4 @@ "keywords": [ | ||
"@mwcp/otel": "20 - 22", | ||
"kmore-cli": "^59.5.2", | ||
"kmore-types": "^59.5.2", | ||
"kmore-cli": "^59.5.3", | ||
"kmore-types": "^59.5.3", | ||
"knex": "^3.1.0", | ||
@@ -74,2 +74,3 @@ "pg": "^8.11.3" | ||
"build": "npm run tsc && tsc-alias && npm run rp", | ||
"build:test": "tsc -p test/tsconfig.json", | ||
"clean": "npm run clean:lock && npm run clean:dist && npm run clean:log", | ||
@@ -81,5 +82,5 @@ "clean:cache": "rm -rf .eslintcache .tsbuildinfo", | ||
"cov": "c8 --all npm run test -- --parallel=false", | ||
"lint": "eslint --fix --cache {src,test}/**/*.ts", | ||
"lint:nofix": "eslint --cache {src,test}/**/*.ts", | ||
"pretest": "npm run build", | ||
"lint": "eslint --fix --cache src test", | ||
"lint:nofix": "eslint --cache src test", | ||
"pretest": "npm run build && npm run build:test", | ||
"rp": "tsx bin-hashbang.js", | ||
@@ -89,3 +90,3 @@ "test": "cross-env NODE_ENV=test TS_NODE_PROJECT=test/tsconfig.json mocha --jobs=2", | ||
}, | ||
"gitHead": "c985178b5bddb45f70fd8c9b58a04c76f1093f2f" | ||
"gitHead": "137fd257e3cc2ab34a35e3e04c9b49a65f3c7277" | ||
} |
@@ -36,3 +36,3 @@ import assert from 'node:assert' | ||
const outputMaping = pagingOptions.wrapOutput === true | ||
const outputMaping = pagingOptions.wrapOutput | ||
? { ...initPageTypeMaping } | ||
@@ -142,5 +142,3 @@ : void 0 | ||
} | ||
async function genBuilderForPaging( | ||
options: PagerOptions, | ||
): Promise<GenBuilderForPagingRetType> { | ||
async function genBuilderForPaging(options: PagerOptions): Promise<GenBuilderForPagingRetType> { | ||
@@ -155,3 +153,3 @@ const { kmore, builder } = options | ||
// @ts-ignore | ||
const method = builder['_method'] as string | ||
const method = builder._method as string | ||
assert( | ||
@@ -158,0 +156,0 @@ method === 'select', |
@@ -56,3 +56,3 @@ import assert from 'node:assert' | ||
} | ||
return callCbOnStart({ | ||
callCbOnStart({ | ||
...opts, | ||
@@ -65,14 +65,18 @@ builder, | ||
'query', | ||
(data: OnQueryData) => callCbOnQuery({ | ||
...opts, | ||
data, | ||
}), | ||
(data: OnQueryData) => { | ||
callCbOnQuery({ | ||
...opts, | ||
data, | ||
}) | ||
}, | ||
) | ||
.on( | ||
'query-response', | ||
(resp: QueryResponse, respRaw: OnQueryRespRaw) => callCbOnQueryResp({ | ||
...opts, | ||
_resp: resp, | ||
respRaw, | ||
}), | ||
(resp: QueryResponse, respRaw: OnQueryRespRaw) => { | ||
callCbOnQueryResp({ | ||
...opts, | ||
_resp: resp, | ||
respRaw, | ||
}) | ||
}, | ||
) | ||
@@ -79,0 +83,0 @@ .on( |
@@ -92,3 +92,3 @@ /* eslint-disable max-params */ | ||
const kmoreQueryId = Symbol(`${kmore.dbId}-${Date.now()}`) | ||
const kmoreQueryId = Symbol(`${kmore.dbId}-${Date.now().toString()}`) | ||
@@ -118,3 +118,3 @@ // @ts-ignore | ||
kmore, | ||
refTable as KmoreQueryBuilder, | ||
refTable, | ||
caseConvert, | ||
@@ -121,0 +121,0 @@ ctx, |
@@ -0,1 +1,2 @@ | ||
/* eslint-disable @typescript-eslint/unified-signatures */ | ||
/* eslint-disable max-len */ | ||
@@ -33,3 +34,3 @@ /* eslint-disable @typescript-eslint/no-namespace */ | ||
TRecord extends {} = any, | ||
TResult = any | ||
TResult = any, | ||
> = QueryBuilderExtName<D> | ||
@@ -46,3 +47,3 @@ & QueryBuilderExtMethod<D, CaseConvert, EnablePage, TRecord> | ||
TRecord extends {} = any, | ||
TResult = any | ||
TResult = any, | ||
> extends | ||
@@ -62,3 +63,3 @@ Knex.ChainableInterface<AddPagingMeta<ResolveResult<TResult>, EnablePage>>, | ||
Prefix extends string, | ||
CaseConvert extends CaseType | ||
CaseConvert extends CaseType, | ||
> = { | ||
@@ -165,3 +166,3 @@ /** ref_tb_name: () => knex('tb_name') */ | ||
TSelection, | ||
EnablePage extends PagingCategory = 0 | ||
EnablePage extends PagingCategory = 0, | ||
> = EnablePage extends 0 | ||
@@ -183,3 +184,3 @@ ? TSelection | ||
EnablePage extends PagingCategory = 0, | ||
TResult = unknown[] | ||
TResult = unknown[], | ||
> = < | ||
@@ -257,3 +258,3 @@ TRecord1 = UnwrapArrayMember<TResult>, | ||
EnablePage extends PagingCategory = 0, | ||
TRecord extends {} = any, TResult = unknown[] | ||
TRecord extends {} = any, TResult = unknown[], | ||
> extends | ||
@@ -268,3 +269,3 @@ AliasQueryBuilder<D, CaseConvert, EnablePage, TRecord, TResult>, | ||
TInnerRecord extends {} = any, | ||
TInnerResult = any | ||
TInnerResult = any, | ||
>( | ||
@@ -277,3 +278,3 @@ ...subQueryBuilders: readonly KmoreQueryBuilder<D, CaseConvert, EnablePage, TInnerRecord, TInnerResult>[] | ||
TInnerRecord extends {} = any, | ||
TInnerResult = any | ||
TInnerResult = any, | ||
>( | ||
@@ -290,3 +291,3 @@ subQueryBuilders: readonly KmoreQueryBuilder<D, CaseConvert, EnablePage, TInnerRecord, TInnerResult>[] | ||
TRecord extends {} = any, | ||
TResult = unknown[] | ||
TResult = unknown[], | ||
> { | ||
@@ -302,3 +303,3 @@ | ||
IncompatibleToAlt<ArrayMember<AliasUT>, string, never>, Knex.IntersectAliases<AliasUT>> | ||
> | ||
>, | ||
>( | ||
@@ -316,3 +317,3 @@ ...aliases: AliasUT | ||
IncompatibleToAlt<ArrayMember<AliasUT>, string, never>, Knex.IntersectAliases<AliasUT>> | ||
> | ||
>, | ||
>( | ||
@@ -330,3 +331,3 @@ aliases: AliasUT | ||
IncompatibleToAlt<ArrayMember<AliasUT>, string, never>, Knex.IntersectAliases<AliasUT> > | ||
> | ||
>, | ||
>( | ||
@@ -344,3 +345,3 @@ ...aliases: AliasUT | ||
IncompatibleToAlt<ArrayMember<AliasUT>, string, never>, Knex.IntersectAliases<AliasUT> > | ||
> | ||
>, | ||
>( | ||
@@ -357,3 +358,3 @@ aliases: AliasUT | ||
TRecord extends {} = any, | ||
TResult = unknown[] | ||
TResult = unknown[], | ||
> { | ||
@@ -377,3 +378,3 @@ | ||
ColNameUT & string | ||
>[] | ||
>[], | ||
>( | ||
@@ -389,3 +390,3 @@ ...columnNames: readonly ColNameUT[] | ||
ColNameUT & string | ||
>[] | ||
>[], | ||
>( | ||
@@ -402,3 +403,3 @@ columnNames: readonly ColNameUT[] | ||
keyof TRecord & string | ||
>[] | ||
>[], | ||
>( | ||
@@ -413,3 +414,3 @@ ...columnNames: readonly Knex.ColumnDescriptor<TRecord, TResult>[] | ||
keyof TRecord & string | ||
>[] | ||
>[], | ||
>( | ||
@@ -426,3 +427,3 @@ columnNames: readonly Knex.ColumnDescriptor<TRecord, TResult>[] | ||
TRecord extends {} = any, | ||
TResult = unknown[] | ||
TResult = unknown[], | ||
> { | ||
@@ -443,17 +444,19 @@ | ||
( | ||
columnDefs: (| keyof TRecord | ||
| Readonly<{ | ||
column: keyof TRecord | QueryBuilder, | ||
order?: 'asc' | 'desc' | undefined, | ||
nulls?: 'first' | 'last' | undefined, | ||
}>)[] | ||
columnDefs: ( | ||
| keyof TRecord | ||
| Readonly<{ | ||
column: keyof TRecord | QueryBuilder, | ||
order?: 'asc' | 'desc' | undefined, | ||
nulls?: 'first' | 'last' | undefined, | ||
}>)[] | ||
): KmoreQueryBuilder<D, CaseConvert, EnablePage, TRecord, TResult> | ||
( | ||
columnDefs: (| string | ||
| Readonly<{ | ||
column: string | QueryBuilder, | ||
order?: string | undefined, | ||
nulls?: string | undefined, | ||
}>)[] | ||
columnDefs: ( | ||
| string | ||
| Readonly<{ | ||
column: string | QueryBuilder, | ||
order?: string | undefined, | ||
nulls?: string | undefined, | ||
}>)[] | ||
): KmoreQueryBuilder<D, CaseConvert, EnablePage, TRecord, TResult> | ||
@@ -468,4 +471,4 @@ } | ||
? (<U>() => U extends T ? 0 : 1) extends <U>() => U extends {} ? 0 : 1 | ||
? any | ||
: T | ||
? any | ||
: T | ||
: never | ||
@@ -537,3 +540,3 @@ type Dict<T = any> = Record<string, T> | ||
// Extra props which will be unioned with the result | ||
TUnionProps = never | ||
TUnionProps = never, | ||
> { | ||
@@ -596,3 +599,3 @@ // These properties are not actually used, but exist simply because | ||
TSelection, | ||
TSingle extends boolean | ||
TSingle extends boolean, | ||
> = TSelection extends DeferredKeySelection< | ||
@@ -620,3 +623,3 @@ infer TBase, | ||
TSelection, | ||
TKey extends string | ||
TKey extends string, | ||
> = TSelection extends DeferredKeySelection< | ||
@@ -644,3 +647,3 @@ infer TBase, | ||
TSelection, | ||
T extends {} | ||
T extends {}, | ||
> = TSelection extends DeferredKeySelection< | ||
@@ -692,3 +695,3 @@ infer TBase, | ||
TKey extends string, | ||
TAliasMapping extends {} = {} | ||
TAliasMapping extends {} = {}, | ||
> = AddAliases<AddKey<SetBase<T, TBase>, TKey>, TAliasMapping> | ||
@@ -712,3 +715,3 @@ | ||
// So we compromise on type safety here and return any. | ||
| AugmentParams< | ||
| AugmentParams< | ||
AnyToUnknown<TBase> extends {} | ||
@@ -755,3 +758,3 @@ ? // ^ Conversion of any -> unknown is needed here to prevent distribution | ||
TRecord extends {} = any, | ||
TResult = any | ||
TResult = any, | ||
> extends WhereRaw<D, CaseConvert, EnablePage, TRecord, TResult> { | ||
@@ -786,3 +789,3 @@ | ||
TRecordInner extends {}, | ||
TResultInner | ||
TResultInner, | ||
>( | ||
@@ -814,3 +817,3 @@ columnName: T, | ||
TRecord extends {} = any, | ||
TResult = unknown[] | ||
TResult = unknown[], | ||
> | ||
@@ -817,0 +820,0 @@ extends Knex.RawQueryBuilder<TRecord, TResult> { |
@@ -42,3 +42,3 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ | ||
event.dbId = options.dbId | ||
return cb(event, options.ctx) | ||
cb(event, options.ctx); return | ||
} | ||
@@ -63,3 +63,3 @@ } | ||
event.dbId = options.dbId | ||
return cb(event, options.ctx) | ||
cb(event, options.ctx); return | ||
} | ||
@@ -85,3 +85,3 @@ } | ||
event.dbId = options.dbId | ||
return cb(event, options.ctx) | ||
cb(event, options.ctx); return | ||
} | ||
@@ -127,3 +127,4 @@ } | ||
case 'query': { | ||
const data = input.data as OnQueryData | ||
const { data } = input | ||
assert(data, 'data should be set on query event') | ||
ev.method = data.method ? data.method : '' | ||
@@ -136,3 +137,4 @@ ev.kUid = data.__knexUid | ||
case 'queryResponse': { | ||
const data = input.respRaw as OnQueryRespRaw | ||
const data = input.respRaw | ||
assert(data, 'data should be set on queryResponse event') | ||
ev.method = data.method ? data.method : '' | ||
@@ -146,3 +148,4 @@ ev.command = data.response?.command | ||
case 'queryError': { | ||
const data = input.exData as OnQueryErrorData | ||
const data = input.exData | ||
assert(data, 'data should be set on queryError event') | ||
ev.method = data.method | ||
@@ -149,0 +152,0 @@ ev.kUid = data.__knexUid |
@@ -33,3 +33,7 @@ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ | ||
case EnumClient.pg: | ||
// eslint-disable-next-line no-fallthrough | ||
case EnumClient.pgnative: | ||
// eslint-disable-next-line no-fallthrough | ||
case EnumClient.mysql: | ||
@@ -169,7 +173,10 @@ return parseRespCommon(res as RespCommon) | ||
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: | ||
@@ -202,3 +209,3 @@ return result | ||
/** | ||
* Convert keys of result to camelcase, if input is object | ||
* Convert keys of result to camel case, if input is object | ||
*/ | ||
@@ -240,4 +247,4 @@ export function postProcessResponseToCamel<T extends PostProcessInput = PostProcessInput>( | ||
const reulst2 = genCamelKeysFrom(resultNeedConvertKeys) | ||
const ret = Object.assign(resultNotConvertKeys, reulst2) | ||
const results2 = genCamelKeysFrom(resultNeedConvertKeys) | ||
const ret = Object.assign(resultNotConvertKeys, results2) | ||
return ret as PostProcessRespRet<T, CaseType.camel> | ||
@@ -304,4 +311,4 @@ } | ||
const reulst2 = genSnakeKeysFrom(resultNeedConvertKeys) | ||
const ret = Object.assign(resultNotConvertKeys, reulst2) | ||
const results2 = genSnakeKeysFrom(resultNeedConvertKeys) | ||
const ret = Object.assign(resultNotConvertKeys, results2) | ||
return ret as PostProcessRespRet<T, CaseType.snake> | ||
@@ -351,5 +358,3 @@ } | ||
export function genCamelKeysFrom<From extends PostProcessRecord>( | ||
input: From, | ||
): RecordCamelKeys<From, '_'> { | ||
export function genCamelKeysFrom<From extends PostProcessRecord>(input: From): RecordCamelKeys<From, '_'> { | ||
return camelKeys(input) | ||
@@ -364,5 +369,3 @@ } | ||
export function genSnakeKeysFrom<From extends PostProcessRecord>( | ||
input: From, | ||
): RecordSnakeKeys<From, '_'> { | ||
export function genSnakeKeysFrom<From extends PostProcessRecord>(input: From): RecordSnakeKeys<From, '_'> { | ||
return snakeKeys(input) | ||
@@ -369,0 +372,0 @@ } |
@@ -223,5 +223,3 @@ /* eslint-disable max-lines-per-function */ | ||
getTrxSetByCtx( | ||
ctx: unknown, | ||
): Set<KmoreTransaction> { | ||
getTrxSetByCtx(ctx: unknown): Set<KmoreTransaction> { | ||
@@ -228,0 +226,0 @@ const ret = new Set<KmoreTransaction>() |
@@ -35,3 +35,3 @@ import assert from 'node:assert' | ||
'Transaction already completed, may committed or rollbacked already. trxIdQueryMap not contains kmoreTrxId:' | ||
+ kmoreTrxId.toString(), | ||
+ kmoreTrxId.toString(), | ||
) | ||
@@ -38,0 +38,0 @@ qidSet.add(qid) |
@@ -47,3 +47,3 @@ import assert from 'assert' | ||
return refTable as KmoreQueryBuilder | ||
return refTable | ||
} | ||
@@ -65,3 +65,3 @@ | ||
} | ||
if (wrapOutput === true) { | ||
if (wrapOutput) { | ||
opts.wrapOutput = true | ||
@@ -68,0 +68,0 @@ } |
@@ -22,5 +22,3 @@ /* eslint-disable @typescript-eslint/no-redundant-type-constituents */ | ||
export async function processThenRet( | ||
options: ProcessThenRetOptions, | ||
): Promise<unknown> { | ||
export async function processThenRet(options: ProcessThenRetOptions): Promise<unknown> { | ||
@@ -80,3 +78,3 @@ const { | ||
if (resp && typeof resp === 'object' | ||
&& ! Object.hasOwn(resp, KmoreProxyKey.getThenProxyProcessed) | ||
&& ! Object.hasOwn(resp, KmoreProxyKey.getThenProxyProcessed) | ||
) { | ||
@@ -152,5 +150,8 @@ Object.defineProperty(resp, KmoreProxyKey.getThenProxyProcessed, { | ||
} | ||
if (ex) { | ||
if (ex instanceof Error) { | ||
return Promise.reject(ex) | ||
} | ||
else { | ||
return Promise.reject(new Error('Kmore Error when executing then()', { cause: ex })) | ||
} | ||
} |
@@ -6,5 +6,3 @@ import type { CreateQueryBuilderGetProxyOptions } from './base.js' | ||
export function createQueryBuilderGetProxy( | ||
options: CreateQueryBuilderGetProxyOptions, | ||
): KmoreQueryBuilder { | ||
export function createQueryBuilderGetProxy(options: CreateQueryBuilderGetProxyOptions): KmoreQueryBuilder { | ||
@@ -35,2 +33,3 @@ const { | ||
}) | ||
default: | ||
@@ -37,0 +36,0 @@ // eslint-disable-next-line @typescript-eslint/no-unsafe-return |
@@ -102,3 +102,3 @@ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ | ||
const method = builder._method as string | ||
const tablesJoin = builder._tablesJoin as string[] | ||
const tablesJoin = builder._tablesJoin | ||
console.info(`[Kmore]: patchWhereColumnAlias() column mapping not found: ${column}, will keep original`, { | ||
@@ -105,0 +105,0 @@ dbId, |
@@ -9,5 +9,3 @@ import assert from 'assert' | ||
export function processJoinTableColumnAlias( | ||
builder: KmoreQueryBuilder, | ||
): KmoreQueryBuilder { | ||
export function processJoinTableColumnAlias(builder: KmoreQueryBuilder): KmoreQueryBuilder { | ||
@@ -52,5 +50,3 @@ if (! builder._tablesJoin.length) { | ||
export function extRefTableFnPropertySmartJoin( | ||
refTable: KmoreQueryBuilder, | ||
): KmoreQueryBuilder { | ||
export function extRefTableFnPropertySmartJoin(refTable: KmoreQueryBuilder): KmoreQueryBuilder { | ||
@@ -69,3 +65,3 @@ Object.values(SmartKey).forEach((joinType) => { | ||
return refTable as KmoreQueryBuilder | ||
return refTable | ||
} | ||
@@ -72,0 +68,0 @@ |
@@ -76,3 +76,3 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ | ||
export interface KmoreEvent <T = unknown> { | ||
export interface KmoreEvent<T = unknown> { | ||
dbId: string | ||
@@ -133,3 +133,3 @@ type: EventType | ||
export interface OnQueryRespRaw <T = unknown> { | ||
export interface OnQueryRespRaw<T = unknown> { | ||
__knexUid: string // '__knexUid3' | ||
@@ -148,3 +148,3 @@ __knexTxId: string | undefined // 'trx2' | ||
} | ||
export interface QueryResponse <T = unknown> { | ||
export interface QueryResponse<T = unknown> { | ||
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents | ||
@@ -151,0 +151,0 @@ _parsers: unknown[] | any |
@@ -10,3 +10,3 @@ import assert from 'node:assert' | ||
if (! id) { | ||
const str = `trx-${Date.now()}` + (suffix ? `-${suffix}` : '') | ||
const str = `trx-${Date.now().toString()}` + (suffix ? `-${suffix}` : '') | ||
return Symbol(str) | ||
@@ -24,3 +24,3 @@ } | ||
assert(key, 'retrieve key from id failed, input should like "Symbol(trx-1234567890)"') | ||
key2 = `${key}-${Date.now()}` | ||
key2 = `${key}-${Date.now().toString()}` | ||
} | ||
@@ -34,3 +34,3 @@ else if (str.startsWith('trx-')) { | ||
const key3 = suffix ? `${key2}-${suffix}` : `${key2}-${Date.now()}` | ||
const key3 = suffix ? `${key2}-${suffix}` : `${key2}-${Date.now().toString()}` | ||
assert(key3 !== str, 'result should not equal to the input id') | ||
@@ -37,0 +37,0 @@ return Symbol(key3) |
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
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
328172
5791